第一步:
@ContextConfiguration("/applicationContext.xml")
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
@Autowired
private IWorkflowOperateService workflowOperateService;
@Test
public void testA() {
System.out.println(workflowOperateService.getTracingBeforeWaitingNode("2507"));
}
}
第二步:
Right click on project in Package Explorer, go to Properties, go to Libraries tab, click on 'Add Library'
button, select JUnit, click Next >. You should be able to handle it from there.
項目右鍵,點java build path,點Add library按鈕,選junit
說明:@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
加上這個後,執行完測試方法後數據會回滾,既能保證正常測試,又可不影響數據庫中數據。