6 ms·
This is how it's supposed to be done but you always end-up moving them to header just to make writing unit tests less painful.
by hbossy 3y ago
This is how it's supposed to be done but you always end-up moving them to header just to make writing unit tests less painful.
- 10000truths 3y agoThis is a smell. Your unit tests should not have to rely on internal implementation details.
- gpderetta 3y agoAnd in the worst case you can have module-private headers. No need to pollute your interface.
- coldtea 3y agoThey don't have to and shouldn't, but it's convenient. That's the parent's point ("to make writing unit tests less painful").
- icedchai 3y agoAre unit tests common in C? In the mid-2000's, I worked on an "enterprise" system, written in C and C++. There were about 300,000 lines of code, maybe 10 tests. This thing was the core of a billion dollar business
- not2b 3y agoThat's very broken; more usual practice at the time was to have large numbers of tests, aiming for good code coverage. I've sometimes seen too many full-tool tests and few true unit tests (tests that just test functions for correctness), but "maybe 10 tests" is frightening.
- icedchai 3y agoThis particular company was very heavy on manual testing, unfortunately. (This was roughly 2003 - 2006 ish.)