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
@Tagcan help you . Just tag theBaseclasswith a tag such as :Then depending on how you run the test , you can specify you only want to run the tests with the tag
baseClassTestmeaning that to run all tests the extendsBaseclass. So if a new test class that extendsBaseClassis added , it also will be covered.