concept unit in category java

appears as: A unit, unit, unit, units, The unit
JUnit in Action

This is an excerpt from Manning's book JUnit in Action.

Unit test—A test that examines the behavior of a distinct unit of work. A unit of work is a task that is not directly dependent on the completion of any other task. Within a Java application, the distinct unit of work is often, but not always, a single method. In contrast, integration tests and acceptance tests examine how various components interact.

The result of running the unit tests for the Passenger and Flight classes is successful and the code coverage is 100%, as shown in figure 22.2.

Figure 22.2 The unit tests for Passenger and Flight check the correct behavior of the individual classes and run successfully.
JUnit in Action, Second Edition

This is an excerpt from Manning's book JUnit in Action, Second Edition.

A unit test examines the behavior of a distinct unit of work. Within a Java application, the “distinct unit of work” is often (but not always) a single method. By contrast, integration tests and acceptance tests examine how various components interact. A unit of work is a task that isn’t directly dependent on the completion of any other task.

In the second part of the book we explained what mock objects are and how to benefit from using them. We also described different techniques for unit testing your server-side code, and we even compared these techniques against each other. The one thing that you should be aware of now is that there is no absolute truth—the best techniques to use depend on the situation you’re currently in. For example, in most cases you might find server-side testing with mocks and stubs sufficient, but as you saw, this technique suffers some significant drawbacks. That’s why we cover the in-container testing approach deeper in the book. Furthermore, this chapter focuses on the in-container testing methodologies by means of one of the most popular in-container testing frameworks: Cactus. We start by introducing the Cactus framework and then show you some real-world examples of how to use Cactus.

14.4.3. Unit testing a JSP in isolation with Cactus

The strategy for unit testing JSPs in isolation with Cactus is defined in figure 14.3.

Figure 14.3. Strategy to unit test JSPs with Cactus