阅读背景:

为什么JUnit的ExpectedException不会导致不可预测的状态?

来源:互联网 

From the documentation:

从文档:

public class SimpleExpectedExceptionTest {
     @Rule
     public ExpectedException thrown= ExpectedException.none();

     @Test
     public void throwsNothing() {
         // no exception expected, none thrown: passes.
     }

     @Test
     public void throwsExceptionWithSpecificType() {
         thrown.expect(NullPointerException.class);
         throw new NullPointerException();
     }
 }
public class S



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: