@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());
}
}
I would expect that the user would not be present in the database after the completion of the test but it is. The Spring Integration Tests documentation describes that the tests rollback automatically and also that @Rollback
does not let the transaction be committed.
What am I doing wrong?