Test Overview
This test verifies a method that accepts multiple parameter types using JUnit's parameterized test feature. It checks that the method correctly processes different combinations of input values.
This test verifies a method that accepts multiple parameter types using JUnit's parameterized test feature. It checks that the method correctly processes different combinations of input values.
import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; public class CalculatorTest { public static int add(int a, int b) { return a + b; } @ParameterizedTest @CsvSource({ "1, 2, 3", "-1, 1, 0", "100, 200, 300", "0, 0, 0" }) void testAddMultipleParameters(int a, int b, int expected) { assertEquals(expected, add(a, b)); } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | JUnit test runner initializes CalculatorTest class | - | PASS |
| 2 | Runs parameterized test with parameters (1, 2, 3) | Method add(1, 2) is called | Check if add(1, 2) == 3 | PASS |
| 3 | Runs parameterized test with parameters (-1, 1, 0) | Method add(-1, 1) is called | Check if add(-1, 1) == 0 | PASS |
| 4 | Runs parameterized test with parameters (100, 200, 300) | Method add(100, 200) is called | Check if add(100, 200) == 300 | PASS |
| 5 | Runs parameterized test with parameters (0, 0, 0) | Method add(0, 0) is called | Check if add(0, 0) == 0 | PASS |
| 6 | All parameterized tests completed | Test suite finished with all assertions passed | - | PASS |