@SpringBootTest(classes = RepositoryMain.class)
@ActiveProfiles({"dev"})
public class EmployeeTest extends AbstractTransactionalTestNGSpringContextTests {
@Autowired
private EmployeeRepository employeeRepository;
@Test
public void testAddEmployee() {
/// some logic
}
}
此testAddEmployee()
测试用例将一条记录插入到Cassandra数据库employee表中。当我为MySQL存储库编写相同的测试时,它在测试用例前后均保持MySQL状态不变。
为什么AbstractTransactionalTestNGSpringContextTests
不适用于Cassandra?是因为Cassandra不支持提交和汇总功能吗?
为什么AbstractTransactionalTestNGSpringContextTests不适用于Cassandra?是因为Cassandra不支持提交和汇总功能吗?
是,这个正确。
您在MySQL中看到的数据库清理是通过回滚实现的,但是不适用于Cassandra。
您必须明确进行清理。