通常建立maven項目,都會自動在pom.xml文件裏添加好junit的依賴,去掉scoap。java
@RunWith(Suite.class) @Suite.SuiteClasses({ Class1Test.class,Class2Test.class }) public class SuitTest { }
@RunWith(Parameterized.class) public class UserTest { private int expected; private int first; private int second; public UserTest(int expectedResult, int firstNumber, int secondNumber) { this.expected = expectedResult; this.first = firstNumber; this.second = secondNumber; } @Parameters public static Collection addedNumbers() { return Arrays.asList(new Integer[][] { { 3, 1, 2 }, { 5, 2, 3 }, { 7, 3, 4 }, { 9, 4, 5 }, }); } @Test public void sum() { User user = new User(); System.out.println("Addition with parameters : " + first + " and " + second); assertEquals(expected, user.sum(first, second)); } }