Chapter 4Organizing Your Tests

Prior chapters have given you enough unit-testing fodder to hit the ground running. The problem with hitting the ground running, however, is that you’re leaping into a new, unfamiliar environment, and you’re liable to make a few wrong turns or even hurt yourself in the process.

Better that you take a few minutes to pick up a few pointers on what you’re getting into. This chapter introduces a few JUnit features as part of showing you how to best organize and structure your tests.

Some of the topics you’ll read about include:

  • How to make your tests visually consistent using arrange-act-assert

  • Keeping tests maintainable by testing behavior, not methods

  • The importance of test naming

  • Using @Before and @After for common ...

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.