Reputation: 88197
I want to setup my testing database with test data before I start my tests. I suppose I should run that once at the start of the unit tests instead of before each test class for function? How might I do that?
Upvotes: 0
Views: 729
Reputation: 15608
For what it's worth, TestNG supports this with @BeforeSuite and @AfterSuite (and many more configuration annotations).
Upvotes: 0
Reputation: 4895
The accepted solution to How to load DBUnit test data once per case with Spring Test will do this. It works across an arbitrary set of test cases.
Upvotes: 1
Reputation: 31454
You can achieve that with @SuiteClasses
annotation:
@RunWith(Suite.class)
@SuiteClasses({UserDaoTests.class, OrderDaoTests.class})
public class TestSuiteSetup {
@BeforeClass
public static void setUpDatabase() {
// ...
}
@AfterClass
public static void tearDownDatabase() {
// ...
}
}
Tests from UserDaoTests
and OrderDaoTests
will be run between setUpDatabase
and tearDownDatabase
methods.
Upvotes: 2