Class JUnit4Adapter
- All Implemented Interfaces:
net.thucydides.core.adapters.TestStrategyAdapter
public class JUnit4Adapter
extends java.lang.Object
implements net.thucydides.core.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 Constructor Description JUnit4Adapter() -
Method Summary
Modifier and Type Method Description java.util.List<net.thucydides.core.model.TestTag>getTagsFor(java.lang.reflect.Method testMethod)java.util.Optional<java.lang.String>getTitleAnnotation(java.lang.reflect.Method testMethod)booleanisAssumptionViolatedException(java.lang.Throwable throwable)booleanisATaggableClass(java.lang.Class<?> testClass)booleanisIgnored(java.lang.reflect.Method method)booleanisSerenityTestCase(java.lang.Class<?> testClass)booleanisTestClass(java.lang.Class<?> testClass)booleanisTestMethod(java.lang.reflect.Method method)booleanisTestSetupMethod(java.lang.reflect.Method method)java.lang.Doublepriority()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
JUnit4Adapter
public JUnit4Adapter()
-
-
Method Details
-
isTestClass
public boolean isTestClass(java.lang.Class<?> testClass)- Specified by:
isTestClassin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
isTestMethod
public boolean isTestMethod(java.lang.reflect.Method method)- Specified by:
isTestMethodin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
isTestSetupMethod
public boolean isTestSetupMethod(java.lang.reflect.Method method)- Specified by:
isTestSetupMethodin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
isSerenityTestCase
public boolean isSerenityTestCase(java.lang.Class<?> testClass)- Specified by:
isSerenityTestCasein interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
isAssumptionViolatedException
public boolean isAssumptionViolatedException(java.lang.Throwable throwable)- Specified by:
isAssumptionViolatedExceptionin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
isATaggableClass
public boolean isATaggableClass(java.lang.Class<?> testClass)- Specified by:
isATaggableClassin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
isIgnored
public boolean isIgnored(java.lang.reflect.Method method)- Specified by:
isIgnoredin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
getTitleAnnotation
public java.util.Optional<java.lang.String> getTitleAnnotation(java.lang.reflect.Method testMethod)- Specified by:
getTitleAnnotationin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
getTagsFor
public java.util.List<net.thucydides.core.model.TestTag> getTagsFor(java.lang.reflect.Method testMethod)- Specified by:
getTagsForin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-
priority
public java.lang.Double priority()- Specified by:
priorityin interfacenet.thucydides.core.adapters.TestStrategyAdapter
-