Test Overview
This test runs in a CI pipeline stage to verify that the Calculator's add method works correctly. It checks if adding two numbers returns the expected sum.
This test runs in a CI pipeline stage to verify that the Calculator's add method works correctly. It checks if adding two numbers returns the expected sum.
import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; public class CalculatorTest { @Test public void testAdd() { Calculator calc = new Calculator(); int result = calc.add(2, 3); assertEquals(5, result, "2 + 3 should equal 5"); } } class Calculator { public int add(int a, int b) { return a + b; } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and loads CalculatorTest class | JUnit test environment initialized | - | PASS |
| 2 | Runs testAdd() method | Calculator instance created | - | PASS |
| 3 | Calls add(2, 3) method | Method returns integer result | - | PASS |
| 4 | Assert that result equals 5 | Result is 5 | assertEquals(5, result) | PASS |
| 5 | Test completes successfully | Test marked as passed in report | - | PASS |