Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most common mistake you make while writing unit tests? [closed]

What is the one most common mistake you make while writing unit tests? Coupling? Lack of cohesion? Try to test too much functionality at once? Not testing enough functionality?

Post some example code if you have an example of that mistake

like image 320
Vasco Duarte Avatar asked Oct 17 '08 19:10

Vasco Duarte


People also ask

What are the errors commonly found during unit testing?

Unit testing considerations What errors are commonly found during Unit Testing? (1) Misunderstood or incorrect arithmetic precedence, (2) Mixed mode operations, (3) Incorrect initialization, (4) Precision inaccuracy, (5) Incorrect symbolic representation of an expression.

Why is writing unit tests so hard?

Developers experience Unit Testing as difficult when they run into these kinds of problems: Classes are tightly coupled to other classes, which makes it hard to test because you need to control those other classes as well when you are writing your tests. This is very, very difficult and very error prone.


2 Answers

Not writing them at all.

like image 196
shoosh Avatar answered Oct 13 '22 23:10

shoosh


Testing too much in one test. My unit tests often take on more of the character of integration tests by not confining themselves to the method under test.

like image 29
tvanfosson Avatar answered Oct 13 '22 23:10

tvanfosson