JUnit 测试始终回滚事务
我正在运行一个简单的JUnit测试,再次测试一个应用程序DAO。问题是我总是得到:
javax.persistence.RollbackException: Transaction marked as rollbackOnly
JUnit 测试是:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:com/my/app/context.xml"}
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
@Transactional
public class PerformanceTest {
@Test
@Transactional(propagation= Propagation.REQUIRES_NEW)
@Rollback(false)
public void testMsisdnCreationPerformance() {
// Create a JPA entity
// Persist JPA entity
}
}
如您所见,我明确声明不回滚此方法。
Spring JUnit 支持是否始终将回滚设置为 true?