I use Spring
+ TestNg
+ Spring Test DBUnit
.
Right now I ran into the issue that Spring Test DBUnit @DatabaseSetups
annotation is executed early than TestNG @BeforeMethod
annotation.
I need to change this behavior to let methods annotated with TestNG @BeforeMethod
to be executed first and only then methods with @DatabaseSetups.
Right now I have the following test class:
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class })
public abstract class BaseTest extends AbstractTestNGSpringContextTests {
@BeforeMethod(alwaysRun=true)
public void setUp() {
//do setup logic
}
@AfterMethod(alwaysRun=true)
public void tearDown() {
// do tearDown logic
}
...
}
Is there any way with Spring @TestExecutionListeners
to change the order of the processing? How to configure these classes in order to execute all @BeforeMethod
first?