What are Test Suites in Junit 5?

A test suite is used to group together and run a number of unit test cases. To run the suite tests in JUnit, both the @RunWith and @Suite annotations are used.

  1. @RunWith has been replaced with @ExtendWith annotation, but it is still used for backward compatibility.

  2. When a class annotated @RunWith(Suite.class) is run, the SuiteClasses annotation specifies which classes should be run.

With the above annotations, the suite's test classes will begin executing one by one.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Below are the steps to create test suites and test runner.

  • Step 1: First, create a simple test class; for example, DemoTest and annotate a method with @test.

  • Step 2: Create a new test class; for example, DemoTest1 and a method annotated with @test.

  • Step 3: To create a testSuite, annotate the class with @RunWith(Suite.class) and @SuiteClasses(class1.class2.....) first.

  • Step 4: To run our test suite, create a Test Runner class.

JUnit test suite increases developer and tester productivity by allowing them to test multiple application scenarios in a single shot rather than testing them individually.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved