我有与 hsqldb 的集成测试(在内存中),现在我需要在我的测试中设置保存点,在 BaseTest 类中,如何在测试中设置保存点(hsqldb(内存中))?
基础测试:
@ContextConfiguration(classes = {TestConfig.class})
public class BaseTest {
@Before
public void savePoint() {
//set savepoint - How can do it this?
}
@After
public void rollBackToSavePoint() {
//roll back to savepoint - How can do it this?
}
}
我的测试:
@RunWith(SpringJUnit4ClassRunner.class)
public class MyTest extends BaseTest {
@Test
public void test1() {
...
}
}
测试配置:
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
@Configuration
@EnableJpaRepositories("database.dao")
@ComponentScan(basePackageClasses = { MyServiceImpl.class})
@EntityScan({"database.model"})
@Import({DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class TestConfig {
...
}