February 2013
Intermediate to advanced
258 pages
7h 26m
English
In short, JUnit test classes are plain old Java classes that have one or more test methods and zero or more setup and teardown methods. JUnit also defines a simple lifecycle for executing the tests it finds.
The following sections will walk you through these fundamental elements of JUnit test classes one by one, starting with declaring test methods.
JUnit tests in their most basic incarnation are regular instance methods marked with a certain annotation. These methods exercise the code they’re testing and make assertions about expected conditions and side effects, making use of APIs provided by JUnit. The following listing shows an example of what a simple JUnit test class might look ...