"It is insanity to keep doing things the same way and expect things to improve."
Writing clean, readable, and maintainable JUnit test cases, just like writing clean code, is an art. A well-written unit test can prevent maintenance nightmare and acts as a system documentation; however, if not used carefully, it can produce meaningless boilerplate test cases. Mistakes are part of the learning process as long as you aren't making them repeatedly. JUnit is not rocket science, so we can practice, follow guidelines, and learn from others to make it perfect.
This chapter covers JUnit guidelines and best practices. The following categories are covered in depth:
Writing meaningful tests
Test smells and refactoring test smells