08-02-2023, 01:45 PM
First of all, I've found a lot of threads on StackOverflow about this, but none of them really helped me, so sorry to ask possibly duplicate question.
I'm running JUnit tests using spring-test, my code looks like this
@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() {
}
...
}
My problem is that I want my tests to NOT influence other tests.
So I'd like to create something like rollback for each test.
I've searched a lot for this, but I've found nothing so far.
I'm using Hibernate and MySql for this
I'm running JUnit tests using spring-test, my code looks like this
@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() {
}
...
}
My problem is that I want my tests to NOT influence other tests.
So I'd like to create something like rollback for each test.
I've searched a lot for this, but I've found nothing so far.
I'm using Hibernate and MySql for this