문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
java:junit:rule [2014/09/25 09:17] kwon37xi |
java:junit:rule [2016/09/18 15:50] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 2: | 줄 2: | ||
| * [[https:// | * [[https:// | ||
| * [[http:// | * [[http:// | ||
| - | * [[http:// | + | * [[http:// |
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| ===== Exception Rule ===== | ===== Exception Rule ===== | ||
| 줄 34: | 줄 37: | ||
| </ | </ | ||
| + | ===== External Resource Rule ===== | ||
| + | * 외부 리소스 초기화/ | ||
| + | * 대부분의 Custom Rule은 External Resource Rule을 상속 받아 만들어도 충분한 경우가 많다. | ||
| + | <code java> | ||
| + | public static class UsesExternalResource { | ||
| + | Server myServer = new Server(); | ||
| + | |||
| + | @Rule | ||
| + | public ExternalResource resource = new ExternalResource() { | ||
| + | @Override | ||
| + | protected void before() throws Throwable { | ||
| + | myServer.connect(); | ||
| + | }; | ||
| + | |||
| + | @Override | ||
| + | protected void after() { | ||
| + | myServer.disconnect(); | ||
| + | }; | ||
| + | }; | ||
| + | |||
| + | @Test | ||
| + | public void testFoo() { | ||
| + | new Client().run(myServer); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| ===== System Rules ===== | ===== System Rules ===== | ||
| * http:// | * http:// | ||