The open source JUnit unit testing tool has been a blessing for Java developers. However, many programmers think that it is enough to learn the JUnit API and write a few tests in order to have a well-tested application. This idea is more dangerous than not doing unit tests because it leads to a wrong sense of code quality. Learning JUnit is the easiest part of unit testing your Java code, but writing good tests is the hard part.
This article presents some common JUnit anti-patterns and shows how to resolve them. The anti-patterns discussed in this article are:
* Happy path tests
* Validation and boundary tests
* Easy tests
* Overly complex tests