Test Overview
This test uses JUnit's @ValueSource to run the same test method multiple times with different simple input values. It verifies that the input strings are not empty.
This test uses JUnit's @ValueSource to run the same test method multiple times with different simple input values. It verifies that the input strings are not empty.
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import static org.junit.jupiter.api.Assertions.assertFalse; public class SimpleValueSourceTest { @ParameterizedTest @ValueSource(strings = {"apple", "banana", "cherry"}) void testStringIsNotEmpty(String fruit) { assertFalse(fruit.isEmpty(), "String should not be empty"); } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and identifies the parameterized test method with @ValueSource | JUnit test environment ready to run tests | - | PASS |
| 2 | Test method 'testStringIsNotEmpty' runs with input 'apple' | Test method executing with parameter fruit='apple' | Check that 'apple'.isEmpty() is false | PASS |
| 3 | Test method 'testStringIsNotEmpty' runs with input 'banana' | Test method executing with parameter fruit='banana' | Check that 'banana'.isEmpty() is false | PASS |
| 4 | Test method 'testStringIsNotEmpty' runs with input 'cherry' | Test method executing with parameter fruit='cherry' | Check that 'cherry'.isEmpty() is false | PASS |
| 5 | All parameterized test runs complete | Test suite finished | All assertions passed for all inputs | PASS |