Chapter 3. Organizing and building JUnit tests

This chapter covers

  • Deciding where to place production code and test code
  • Dealing with duplicate test code
  • Organizing special case tests
  • Building tests in various development environments

Once you understand the fundamentals of writing JUnit tests, the next step is to begin writing them. Once you open your favorite Java editor and begin writing test code, you need to decide into which package you should place the test code. Although this decision seems simple enough, there is a considerable difference between placing your test code in the same package as your production code[1] or in a different package. For that reason, we offer a few recipes to help you decide which to do.

1 We will use ...

Get JUnit Recipes 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.