I am using jUnit to manage integration tests for an application that accesses a database. Because setting up the test data is a time-consuming operation, I have been doing that in the @BeforeClass
method, which is executed only once per test class (as opposed to the @Before
method, which is run once per test method).
Now I want to try a few different permutations for the configuration of the data layer, running all of my tests on each different configuration. This seems like a natural use of the Parameterized
test runner. Problem is, Parameterized
supplies parameters to the class constructor, and the @BeforeClass
method is abstract and is called before the class constructor.
A few questions,
Does Parameterized
call the @BeforeClass
method for each permutation of parameters, or does it only call once?
If the @BeforeClass
method is called repeatedly, is there some way to access the parameter values from inside of it?
If none of these, what do people suggest as the best alternative approach to this problem?