Test Overview
This test suite groups two simple test classes using JUnit's @Suite annotation. It verifies that all tests in the suite run and pass successfully.
This test suite groups two simple test classes using JUnit's @Suite annotation. It verifies that all tests in the suite run and pass successfully.
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; public class TestClassOne { @Test void testOne() { assertTrue(1 + 1 == 2); } } public class TestClassTwo { @Test void testTwo() { assertTrue("hello".startsWith("h")); } } import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @Suite @SelectClasses({TestClassOne.class, TestClassTwo.class}) public class MyTestSuite { // This class remains empty, used only as a holder for the above annotations }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and loads MyTestSuite class | JUnit test runner initialized with suite containing TestClassOne and TestClassTwo | - | PASS |
| 2 | Test runner executes TestClassOne.testOne() | TestClassOne loaded, testOne method ready to run | assertTrue(1 + 1 == 2) verifies 2 equals 2 | PASS |
| 3 | Test runner executes TestClassTwo.testTwo() | TestClassTwo loaded, testTwo method ready to run | assertTrue("hello".startsWith("h")) verifies string starts with 'h' | PASS |
| 4 | Test runner completes execution of all tests in suite | All tests in MyTestSuite executed | All assertions passed | PASS |