If unit testing has not always been adopted by software developers, this practice has become more mainstream with Agile approaches. Test-Driven Development and Continuous Integration are two technical approaches that require good unit testing. In this blog post, Maxime Lemaitre discusses attitudes that might make your unit testing fail.
Here are some of factors that provoke unit testing failure:
* develop first, test after
* think that some piece of code are not concerned
* test useless, irrelevant or multiple things
* It’s just a test: you should consider your test code as production code and apply the same quality rules
* test implementation: consider the code unit as a black box
* remove a unit test only when you have a very good reason
* dependent unit tests or random failures: make each test independent to all the others
* trying to achieve 100% code coverage: code coverage is an important indicator… but not an objective
* using wrong naming convention: you shouldn’t have to view code to understand the test
The conclusion of Maxime Lemaitre is “To summarize, when writing unit test keep in mind those famous properties: Understandable, Maintainable, Repeatable, Necessary, Granular and Fast.”
Read the complete blog post on https://techblog.betclicgroup.com/2014/05/06/getting-unit-testing-to-fail/