读书人

扩充Spring junit4 的TestExecutionLi

发布时间: 2012-11-05 09:35:11 作者: rapoo

扩展Spring junit4 的TestExecutionListener
web单元测试经常会在执行前准备一些数据
执行完毕后删除这些数据 如下伪代码



这样你的testcase只要继承JUnit4TestCase就可以使用BeforeMethod和AfterMethod了

附上BeforeMethod和AfterMethod

@Retention(RetentionPolicy.RUNTIME)@Target({ElementType.METHOD})public @interface BeforeMethod {String[] value() default {};}@Retention(RetentionPolicy.RUNTIME)@Target({ElementType.METHOD})public @interface AfterMethod {String[] value() default {};}


读书人网 >软件架构设计

热点推荐