Unit Testing in C++

J

James Kanze

I never said it wasn't. In legacy code issues (where complete
product lines where developed and designed without unit
testing) it can certainly be the only way to get something
under test. At times like that you absolutely have to cut
corners or you can be left refactoring HUGE chunks of code
without the support of unit tests.

That's a different issue. If you're dealing with legacy code,
or even external code (like Solaris, or Linux:)), then you
sometimes have to resort to mock functions: you may design your
socket wrapper class to support simulating all possible errors,
but Posix didn't take that into consideration when it designed
its socket interface, and if you're going to test your socket
wrapper class, you'll need to provoke all possible error returns
from the system functions---which probably means linking in a
mock library.

The original poster spoke of a problem due to three headers
being in the same directory. IMHO, either the three headers are
so closely related that they form a single unit, or they belong
in different directories. And units should be very loosely
coupled, only depending on lower units in the hierarchy, which
they can "assume" correct and tested. (As I said, you don't
create a mock std::vector.) In an ideal world, of course.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top