문서의 이전 판입니다!
@RunWith(Parameterized.class)
로 지정된다.@Parameters
로 지정된 static 메소드는 배열의 컬렉션을 리턴한다.@RunWith(Parameterized.class) class MyParameterizedClassTest { private int multiplier; public MyParameterizedClassTest(int testParameter) { this.multiplier = testParameter; } // creates the test data @Parameters public static java.util.Collection<Object[]> data() { Object[][] data = new Object[][] { {1}, {5}, {121}}; return Arrays.asList(data); } @Test public void testMultiplyException() { MyClass tester = new MyClass(); assertEquals("Result", multiplier * multiplier, tester.multiply(multiplier, multiplier)); } }
@Rule public ExpectedException exception = ExpectedException.none(); @Test public void throwsIllegalArgumentExceptionIfIconIsNull() { // 발생할 예외에 대한 조건 기술 exception.expect(IllegalArgumentException.class); exception.expectMessage("Negative value not allowed"); ClassToBeTested t = new ClassToBeTested(); t.methodToBeTest(-1); }