Class JUnit4Adapter
- All Implemented Interfaces:
net.thucydides.model.adapters.TestStrategyAdapter
It serves to decouple serenity-model (and serenity-core) from JUnit. If JUnit is on the classpath, JUnit classes will be handled specifically. But serenity will continue to function without JUnit being on the classpath. Furthermore, users can choose between JUnit 4 and JUnit 5 or even use both together.
Ideally this approach could be generalized to avoid any special treatment of JUnit as a test framework. Test-framework specific strategies could be registered from the framework-specific modules. That would allow to place the implementation of (and the tests for) the test-framework specific strategies into the modules that know about those frameworks and also have the necessary dependencies.
But this would be a more extensive change, potentially breaking backwards compatibility. So for now this class does exactly only this: It provides an adapter for JUnit 4 and JUnit 5, and makes explicit the parts of the code where there has previously been a hard dependency on JUnit 4.
As such it is self-contained and should be possible to be grasped rather easily. And it marks the starting point for a potential refactoring towards a more general approach.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<net.thucydides.model.domain.TestTag> getTagsFor(Method testMethod) getTitleAnnotation(Method testMethod) booleanisAssumptionViolatedException(Throwable throwable) booleanisATaggableClass(Class<?> testClass) booleanbooleanisSerenityTestCase(Class<?> testClass) booleanisTestClass(Class<?> testClass) booleanisTestMethod(Method method) booleanisTestSetupMethod(Method method) priority()
-
Constructor Details
-
JUnit4Adapter
public JUnit4Adapter()
-
-
Method Details
-
isTestClass
- Specified by:
isTestClassin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
isTestMethod
- Specified by:
isTestMethodin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
isTestSetupMethod
- Specified by:
isTestSetupMethodin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
isSerenityTestCase
- Specified by:
isSerenityTestCasein interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
isAssumptionViolatedException
- Specified by:
isAssumptionViolatedExceptionin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
isATaggableClass
- Specified by:
isATaggableClassin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
isIgnored
- Specified by:
isIgnoredin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
getTitleAnnotation
- Specified by:
getTitleAnnotationin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
getTagsFor
- Specified by:
getTagsForin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-
priority
- Specified by:
priorityin interfacenet.thucydides.model.adapters.TestStrategyAdapter
-