Top 3 mistakes you're probably doing while unit testing

Fernando Doglio - Sep 25 '19 - - Dev Community

Sometimes the task of writing unit tests is delegated to the new team member or the Jr. developer, in order to help them get to know the code base. That's at least the most convincing excuse I've heard

That being said, if the devs writing these tests don't have prior experience doing so, they can run into some classic mistakes. These are my top 3:

  1. Testing more than one thing at the time. Having big test cases checking for several things at the same time can be a problem.

  2. Relying on external resources. How many times have we seen a "testing database" being created and destroyed during the tests execution?

  3. Finally, aiming for high coverage alone, without context. Coverage by the sake of coverage isn't really helpful, there are better metrics to try to improve and use to measure the success (or lack of thereof) of your tests.

Those are my top 3 mistakes, I've written more about them over here.

What about you? What are the top mistakes you've seen while reviewing (or writing your own) unit tests?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player