문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
java:junit [2012/10/04 10:58] kwon37xi |
java:junit [2015/11/21 13:26] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 2: | 줄 2: | ||
| ===== 읽어 볼 글 ===== | ===== 읽어 볼 글 ===== | ||
| * [[http:// | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | ===== Parameterized Test ===== | ||
| + | * '' | ||
| + | * '' | ||
| + | * 파라미터 컬렉션의 배열은 테스트 클래스의 생성자의 인자로 들어가게 된다. 따라서 생성자 인자수와 파라미터 배열의 크기가 일치해야 한다. | ||
| + | |||
| + | <code java> | ||
| + | @RunWith(Parameterized.class) | ||
| + | class MyParameterizedClassTest { | ||
| + | private int multiplier; | ||
| + | |||
| + | public MyParameterizedClassTest(int testParameter) { | ||
| + | this.multiplier = testParameter; | ||
| + | } | ||
| + | |||
| + | // creates the test data | ||
| + | |||
| + | @Parameterized.Parameters | ||
| + | public static java.util.Collection< | ||
| + | Object[][] data = new Object[][] { {1}, {5}, {121}}; | ||
| + | return Arrays.asList(data); | ||
| + | |||
| + | } | ||
| + | |||
| + | @Test | ||
| + | public void testMultiplyException() { | ||
| + | MyClass tester = new MyClass(); | ||
| + | assertEquals(" | ||
| + | |||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Assume ===== | ||
| + | '' | ||
| + | <code java> | ||
| + | | ||
| + | | ||
| + | | ||
| + | // rest of setup. | ||
| + | } | ||
| + | // someCondition() == true 일 때만 테스트들이 실행된다. | ||
| + | </ | ||
| + | |||
| + | * [[http:// | ||
| + | |||
| + | ===== 테스트 실행 순서 ===== | ||
| + | * 테스트 클래스에 '' | ||
| + | * [[http:// | ||
| + | |||
| + | ===== IntelliJ Live Template for try/catch JUnit/ | ||
| + | * abbrevication : '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * Template text : <code java> | ||
| + | try { | ||
| + | org.junit.Assert.fail(" | ||
| + | } catch ($EXCEPTION$ ex) { | ||
| + | org.junit.Assert.assertThat(" | ||
| + | ex.getMessage(), | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Plugins ===== | ||
| + | * [[https:// | ||