java.lang.Object
net.thucydides.core.adapters.junit4.JUnit4Adapter
All Implemented Interfaces:
net.thucydides.model.adapters.TestStrategyAdapter

public class JUnit4Adapter extends Object implements net.thucydides.model.adapters.TestStrategyAdapter
This is an INTERNAL helper class of serenity, it should not be used directly and may be subject to refactoring.

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 Details

    • JUnit4Adapter

      public JUnit4Adapter()
  • Method Details

    • isTestClass

      public boolean isTestClass(Class<?> testClass)
      Specified by:
      isTestClass in interface net.thucydides.model.adapters.TestStrategyAdapter
    • isTestMethod

      public boolean isTestMethod(Method method)
      Specified by:
      isTestMethod in interface net.thucydides.model.adapters.TestStrategyAdapter
    • isTestSetupMethod

      public boolean isTestSetupMethod(Method method)
      Specified by:
      isTestSetupMethod in interface net.thucydides.model.adapters.TestStrategyAdapter
    • isSerenityTestCase

      public boolean isSerenityTestCase(Class<?> testClass)
      Specified by:
      isSerenityTestCase in interface net.thucydides.model.adapters.TestStrategyAdapter
    • isAssumptionViolatedException

      public boolean isAssumptionViolatedException(Throwable throwable)
      Specified by:
      isAssumptionViolatedException in interface net.thucydides.model.adapters.TestStrategyAdapter
    • isATaggableClass

      public boolean isATaggableClass(Class<?> testClass)
      Specified by:
      isATaggableClass in interface net.thucydides.model.adapters.TestStrategyAdapter
    • isIgnored

      public boolean isIgnored(Method method)
      Specified by:
      isIgnored in interface net.thucydides.model.adapters.TestStrategyAdapter
    • getTitleAnnotation

      public Optional<String> getTitleAnnotation(Method testMethod)
      Specified by:
      getTitleAnnotation in interface net.thucydides.model.adapters.TestStrategyAdapter
    • getTagsFor

      public List<net.thucydides.model.domain.TestTag> getTagsFor(Method testMethod)
      Specified by:
      getTagsFor in interface net.thucydides.model.adapters.TestStrategyAdapter
    • priority

      public Double priority()
      Specified by:
      priority in interface net.thucydides.model.adapters.TestStrategyAdapter