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 |
mvn test.npm run test is for Node.js projects, docker build builds images, and git commit commits code.steps:
- name: Run tests
run: mvn test
continue-on-error: falsemvn test returns an error, so the pipeline stops and marks failure.mvn test with continue-on-error: false stops the build on test failure.Pass the test and this pattern moves unknown