I have an integration test class with following scenario:
I want a sql script to be loaded as first thing. I use for this purpose the Spring @Sql annotation at class level
and then, I have a @BeforeAll (JUnit5) method i'd like to execute only once, after the @Sql has been executed.
My problem is that the content of @BeforeAll is been executed before the import of the @Sql script and not after.
Why is this so, and what can I do to reverse the order?
@SpringBootTest
@Transactional
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Sql(scripts={"classpath:data-postgreForDemoAndIt.sql"}, executionPhase = BEFORE_TEST_METHOD)
public class DatingManagerIT {
(...)
@BeforeAll
public void init() {
MockitoAnnotations.initMocks(this);
Member memberDenise = memberDao.findByEmail("denise@yahoo.fr", Member.class).get();
Member memberAnne = memberDao.findByEmail("anne@yahoo.fr", Member.class).get();
Member memberJulien = memberDao.findByEmail("julien@yahoo.fr", Member.class).get();
memberDao.delete(memberDenise);
memberDao.delete(memberAnne);
memberDao.delete(memberJulien);
memberFactory.createSampleMembers();
}
(...)
}