AbstractTransactionalTestNGSpringContextTests 测试用例更新cassandra数据库
AbstractTransactionalTestNGSpringContextTests test case updates cassandra database
@SpringBootTest(classes = RepositoryMain.class)
@ActiveProfiles({"dev"})
public class EmployeeTest extends AbstractTransactionalTestNGSpringContextTests {
@Autowired
private EmployeeRepository employeeRepository;
@Test
public void testAddEmployee() {
/// some logic
}
}
这个 testAddEmployee()
测试用例向 Cassandra 数据库员工 table 中插入一条记录。当我为 MySQL 存储库编写相同的测试时,它在测试用例前后保持 MySQL 状态不变。
为什么 AbstractTransactionalTestNGSpringContextTests
不能与 Cassandra 一起工作?是因为 Cassandra 不支持 commit 和 rollup 功能吗?
Why does AbstractTransactionalTestNGSpringContextTests not work with Cassandra? Is it because Cassandra does not support commit and rollup functionality?
是的,这是正确的。
您在 MySQL 中看到的数据库清理是通过回滚实现的,但这不适用于 Cassandra。
您必须明确地进行清理。
@SpringBootTest(classes = RepositoryMain.class)
@ActiveProfiles({"dev"})
public class EmployeeTest extends AbstractTransactionalTestNGSpringContextTests {
@Autowired
private EmployeeRepository employeeRepository;
@Test
public void testAddEmployee() {
/// some logic
}
}
这个 testAddEmployee()
测试用例向 Cassandra 数据库员工 table 中插入一条记录。当我为 MySQL 存储库编写相同的测试时,它在测试用例前后保持 MySQL 状态不变。
为什么 AbstractTransactionalTestNGSpringContextTests
不能与 Cassandra 一起工作?是因为 Cassandra 不支持 commit 和 rollup 功能吗?
Why does AbstractTransactionalTestNGSpringContextTests not work with Cassandra? Is it because Cassandra does not support commit and rollup functionality?
是的,这是正确的。
您在 MySQL 中看到的数据库清理是通过回滚实现的,但这不适用于 Cassandra。
您必须明确地进行清理。