Relationship Between Test and Production Code

The JUnit tests you write will live in the same project as the production code that they verify. However, you’ll keep the tests separate from the production code within a given project. You’ll ship the production code (the target of the tests, sometimes known as the system under test or SUT), but the tests will typically stay behind.

When we say the tests you write, we mean you, a programmer. Unit testing is solely a programmer activity. No customers, end users, or nonprogrammers will typically see or run your tests.

Unit testing is a one-way street, as demonstrated in the following figure. Tests depend on the production-system code, but the dependency goes only in that direction. The production ...

Get Pragmatic Unit Testing in Java 8 with 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.