Chapter 1. JUnit 4 – a Total Recall

This chapter covers the unit testing concept, the JUnit 4 framework, the Eclipse setup, and the advanced features of JUnit 4. In JUnit 4, you will be introduced to the JUnit framework briefly to get you up and running. We will discuss the concept surrounding JUnit essentials, annotations, assertion, the @RunWith annotation, and exception handling so that you have an adequate background on how JUnit 4 works. Advanced readers can skip to the next section.

In JUnit 4++, we will explore the advanced topics of JUnit 4 and deep dive into parameterized tests, Hamcrest matchers and assertThat, the assumption, theory, timeout, categories, rules, test suites, and tests order.

Defining unit testing

A test is an assessment ...

Get Mastering Unit Testing Using Mockito and 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.