Configuring tests

This section deals with the test configuration. Unit tests are not testing the system. In TDD, unit tests are written to obtain the following benefits:

  • They drive your design. You write a test, add code to fix the test, refactor code with confidence, and apply the design. This results in a simple, clean, maintainable, loosely coupled, and cohesive design. You write code to satisfy a failing test, so it limits the code you write to only what is needed.
  • The tests provide fast, automated regression for refactoring and enhancing the code.

You should configure your tests to follow the following principles:

  • Unit tests should be executed extremely fast so that they can provide quick feedback. Would you withdraw money from an ATM that takes ...

Get Mastering Unit Testing Using Mockito and JUnit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.