Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status (Travis) Build status



Good tests must have only one statement. In theory, it's hard to disagree with that. But in practice sometimes it's hard to achieve. Some modules under test may have complex preconditions and assumptions, and their simulation may n't fit into one statement.

For example, consider a class, which makes a call to some HTTP API:

  • In order to make a good isolated unit test for such class, one will need to bootstrap and configure mock HTTP server. It is not usually a single-statement operation.
  • If the code for bootstrapping mock HTTP server is located in test code or in BeforeTest/AfterTest blocks, it means that it's coverage is not tracked. It is not tested, yet may contain mistakes.
  • There may be another classes which call the same HTTP API. But the mock server initialization in Before/AfterTest block is not reusable outside the test module.

OO-tests project provides new way of testing object-oriented code. Reusable assertion is a Java class which implements com.pragmaticobjects.oo.tests.Assertion interface. It's aim is to validate some certain invariant on the object under test. As an ordinary classes, assertions may be covered with tests and distributed together with classes, so that developers which extend your code may use them for their own tests.

For the detailed idea description, refer to this blogpost.

OO-tests currently supports only JUnit5. It is highly recommented (but not mandatory) to use OO-tests on OO-atom-based projects.

JUnit 5

In order to start using OO-Tests with JUnit 5, add the maven dependency:


If you use maven surefire plugin below 2.22 version, you must also add dependency on junit-platform-surefire-provider: