import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class ParameterizedTest { private int input; private int expected; public ParameterizedTest(int input, int expected) { this.input = input; this.expected = expected; } @Parameters public static Collection<Object[]> testData() { return Arrays.asList(new Object[][] { { 1, 2 }, { 3, 6 }, { 5, 10 } }); } @Test public void testMultiply() { assertEquals(expected, input * 2); } } <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency>


上一篇:
下一篇:
切换中文