I want to execute two scripts before every test method, but i also want to define some scripts to execute before specific methods. Using Spring framework and @Sql
annotations, is it possible?
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/WEB-INF/application-context.xml")
@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD)
@Sql({ "/database/drop_schema.sql", "/database/create_schema.sql" })
public class CentralServiceTestCase {
// I want to run "drop_schema.sql", "create_schema.sql"
// and "basic_data.sql" here
@Test
@Sql({ "/database/basic_data.sql" })
public void processActionWithSuccess() {
}
// I want to run only "drop_schema.sql" and "create_schema.sql" here
@Test
public void anotherTestMethod() {
}
}
Running this code only basic_data.sql
is executed. How to solve this problem?
Do I will have to remove the @Sql
anotation from class and replicate it for each method with /database/drop_schema.sql
and /database/create_schema.sql
defined?