扩充Spring junit4 的TestExecutionListener

扩展Spring junit4 的TestExecutionListenerweb单元测试经常会在执行前准备一些数据 执行完毕后删除这些数

扩展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 {};}