Date/time logic is hard. Throw in time zones along with daylight saving
and it's even harder. Recently a suite of tests that had happily been
running for months started failing. There were no code changes and all
the tests were somehow related to date/time ranges.
Mock is an overloaded term in software development. Sadly this leads
to developers answering with "mock it" when a mock object may not be
the right solution. Test
Doubles are a more general
term. I should try to use this naming more than I do at present - a goal
This blog has numerous examples of why unit,
is essential. However you still need manual tests. It is foolish to
believe that all testing can be covered by automated tests despite the
bias in this area.
Manual tests can catch anything you may have missed …
A common problem many people ask is - should you test private code? In
short, you shouldn't. You should always test the public api of your code
where possible. This is not always easy. Based on the context of the
code in question there are a few options available.
The use of randomly generated test data seems like a good thing at first
glance. Having worked with several teams that have used this concept I
generally discourage the practice. Consider a simple method that joins
together two strings. A test using random values may look like this.