【发布时间】:2012-07-08 22:39:10
【问题描述】:
我知道如何配置 Spring/JUnit 以在每个测试用例后回滚。 我所追求的是一种为所有测试用例启动和回滚一个事务的方法。
我正在使用@BeforeClass 为几个测试用例准备我的 HSQL 数据库。然后我想在@AfterClass 中的所有测试用例结束后回滚更改。
实现此回滚的最佳方法是什么?
这是我的代码示例:
@BeforeClass
public static void setupDB(){
ApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:/spring/applicationContext-services-test.xml");
//- get beans and insert some records to the DB
...
}
@AfterClass
public static void cleanUp(){
??? what should go here?
}
关于在 AfterClass 中进行回滚的最佳方法有什么想法吗?
谢谢大家..
【问题讨论】: