首先,我在StackOverflow上發現了很多關於此的線程,但沒有一個真正幫助我,因此很抱歉詢問可能重複的問題。@Test之後的回滾事務
我正在使用彈簧測試JUnit測試,我的代碼看起來像這樣
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {})
public class StudentSystemTest {
@Autowired
private StudentSystem studentSystem;
@Before
public void initTest() {
// set up the database, create basic structure for testing
}
@Test
public void test1() {
}
...
}
我的問題是,我想我的測試,以不影響其他測試。 所以我想爲每個測試創建一些類似回滾的東西。 我已經爲此搜尋了很多東西,但到目前爲止我還沒有發現任何東西。 我使用Hibernate和MySQL的這個
回滾是什麼意思?清理數據庫? – Gaurav
將它設置爲與執行'initTest' –