The use case is as follows, I would like to be able to combine parametrized and non parametrized test as well as have different parameters for different parametrized tests.
Using Parameterized.class seems a bit of an overkill as this will blow up the constructor for each new unit test I need to parametrize, also will result in multiple runs of the non parametrized tests which I am not interested in.
So I was thinking about Theories.class , but although multiple @DataPoint
s can be provided, those refer to individual types passed as each argument to the test function and still results in only one function tested.
I would like to achieve something like
@RunWith(Theories.class)
class Test{
@Theory(named="foo")
public void fooTest(Object input) {
}
public static @DataPoints(named="foo") Object[] inputs = {1, 2, 3, 4, 5};
@Theory(named="bar")
public void barTest(Object input) {
}
public static @DataPoints(named="bar") Object[] inputs = {6, 7, 8, 9, 10};
public void bazTest() {
}
}
Where fooTest
is tested with 1, 2, 3, 4, 5
and barTest
with 6, 7, 8, 9, 10
respectively.
Is there a way to achieve that using Theory
s? Is there any alternative to achieve that?