Search This Blog

JUnit 4 Aggregating Tests in Suites

1. Overview

In this guide, we will learn how to run multiple Test Classes at a time. Using Suite as a runner allows you to manually build a suite containing tests from many classes. It is the JUnit 4 equivalent of the JUnit 3.8.x static Test suite() method. To use it, annotate a class with @RunWith(Suite.class) and @SuiteClasses(TestClass1.class, ...). When you run this class, it will run all the tests in all the suite classes. Let's create a simple maven project and demonstrate usage of Suite.

7. Conclusion

In this guide, we have learned the how to create Test Suite for multiple Test Classes by creating a maven project. The source code available for this guide on GitHub. On GitHub, there is a multi-module project and this getting started project is a module of it.