After

The refactored tests are a thing of simplicity. Readers understand what case is being demonstrated by reading a test’s name. They can focus initially on the act part of the test to know what code is getting executed. They read the arrange part to determine the context in which the test is running, and they read the single assert so they know what the expected result is. Each of these digesting actions happens quickly, far more so than before. The time to comprehend tests reduces from perhaps minutes down to handfuls of seconds.

images/aside-icons/tip.png

Seeking to understand your system through its tests motivates you to keep them as clean as they should be. ...

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.