Код: Выделить всё
public class InheritClassTestCheckExtension implements TestTemplateInvocationContextProvider, BeforeEachCallback {
@Override
public void beforeEach(ExtensionContext context) throws Exception {
Class superClass = context.getRequiredTestClass().getSuperclass();
String listClasses = "";
if (superClass doesnt exists or is object, throw a exception) {
throw new Exception("Need to inherit from class A,B or C");
} else {
Continue to the test's
}
}
Код: Выделить всё
junit.jupiter.extensions.autodetection.enabled=true
junit.jupiter.extensions.autodetection.names=com.my.package.InheritClassTestCheckExtension
Подробнее здесь: https://stackoverflow.com/questions/767 ... in-junit-5