Test Smell: Misleading Organization

Knowing which part of the test is the act part, which is the arrange part, and which is the assert can speed up cognition. Use AAA (Keeping Tests Consistent with AAA) to make the intent explicit. The arrows in the following listing show the blank lines to insert:

iloveyouboss/test-8/test/util/SearchTest.java
 
@Test
 
public​ ​void​ returnsMatchesShowingContextWhenSearchStringInContent() {
 
stream = streamOn(​"There are certain queer times and occasions "
 
+ ​"in this strange mixed affair we call life when a man "
 
+ ​"takes this whole universe for a vast practical joke, "
 
+ ​"though the wit thereof he but dimly discerns, and more "
 
+ ​"than suspects that the joke is at nobody's expense but "

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.