문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
java:junit [2013/11/14 15:55] kwon37xi [Parameterized Test] |
java:junit [2015/11/21 13:26] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 3: | 줄 3: | ||
| * [[http:// | * [[http:// | ||
| * [[http:// | * [[http:// | ||
| + | * [[http:// | ||
| ===== Parameterized Test ===== | ===== Parameterized Test ===== | ||
| 줄 36: | 줄 37: | ||
| </ | </ | ||
| - | ===== Exception Rule ===== | + | ===== Assume |
| - | * 예외 발생 | + | '' |
| <code java> | <code java> | ||
| - | @Rule | + | @Before |
| - | public ExpectedException exception = ExpectedException.none(); | + | |
| - | + | org.junit.Assume.assumeTrue(someCondition()); | |
| - | @Test | + | // rest of setup. |
| - | public void throwsIllegalArgumentExceptionIfIconIsNull() { | + | } |
| - | // 발생할 예외에 대한 조건 기술 | + | // someCondition() == true 일 때만 테스트들이 실행된다. |
| - | exception.expect(IllegalArgumentException.class); | + | |
| - | exception.expectMessage(" | + | |
| - | + | ||
| - | | + | |
| - | t.methodToBeTest(-1); | + | |
| - | } | + | |
| </ | </ | ||
| - | ===== 임시 폴더 | + | * [[http:// |
| - | * 테스트 | + | |
| - | <code java> | + | |
| - | @Rule | + | |
| - | public TemporaryFolder folder = new TemporaryFolder(); | + | |
| - | + | ||
| - | // ... | + | |
| - | File createdFolder | + | ===== 테스트 실행 순서 ===== |
| - | File createdFile = folder.newFile("myfilefile.txt" | + | * 테스트 클래스에 '' |
| + | * [[http:// | ||
| + | |||
| + | ===== IntelliJ Live Template for try/catch JUnit/ | ||
| + | * abbrevication : '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * Template text : <code java> | ||
| + | try { | ||
| + | org.junit.Assert.fail("Must throw an exception"); | ||
| + | } catch ($EXCEPTION$ ex) { | ||
| + | org.junit.Assert.assertThat("Must throw an exception", | ||
| + | ex.getMessage(), | ||
| + | } | ||
| </ | </ | ||
| + | ===== Plugins ===== | ||
| + | * [[https:// | ||