JUnit:使用ExpectedException进行异常测试
来源:互联网
Junit中有好几种测试异常的方法。就像我在
中写道的那样,我比较喜欢使用org.junit.rules.ExpectedException规则。一般来说,ExpectedException规则是org.junit.Before, org.junit.After, org.junit.BeforeClass,或者org.junit.AfterClass注解的一种替代方式 ,但是它们的功能更为强大,也更容易在多个工程间或者不同类中进行共享。本文中我会介绍下org.junit.rules.ExpectedException规则的一些高级用法。 中写道的那样,我比较喜欢使用org.junit.r