@Rollback在TestNG集成测试中但在DB中提交了条目

时间:2017-06-17 08:40:00

标签: spring testng spring-transactions

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="button">
  <form action="post">
    <input type="text" class="openButton">
  </form>
</div>

<div class="container">
  <div class="closeButton"></div>
</div>

我希望在完成测试后用户不会出现在数据库中,但确实如此。 Spring Integration Tests文档描述了测试自动回滚以及@ContextConfiguration(classes = { ServiceConfig.class,PersistenceConfiguration.class, MailConfig.class }) @Transactional public class CreateStatsIT extends AbstractTestNGSpringContextTests { @Autowired private UserRepository userRepository; @Test @Rollback @Transactional public void insertUserIT() { User u = new User(1L, "Test"); u = userRepository.save(s); List<User> us = userRepository.findAll(); System.out.println(us.size()); } } 不允许提交事务。

我做错了什么?

0 个答案:

没有答案