I try to run some tests on all classes that extends the same baseclass like:
classe Baseclass {
abstract int method();
}
class A extends Baseclass { int method(){...} }
class B extends Baseclass {int method() {..}}
class Testclass {
@ParameterizedTest
@ValueSource( classes={T extends Baseclass})
void test(Baseclass T){
assertStuff(T..)}}
The Testclass should execute the test method with class A and B. When I add a Class C that extends BaseClass class C should automatically be tested to. Is there a way to do this ?
Think that @Tag
can help you . Just tag the Baseclass
with a tag such as :
@Tag("baseClassTest")
classe Baseclass {
abstract int method();
}
Then depending on how you run the test , you can specify you only want to run the tests with the tag baseClassTest
meaning that to run all tests the extends Baseclass
. So if a new test class that extends BaseClass
is added , it also will be covered.