Class JDoctestEngine

java.lang.Object
net.cscott.jdoctest.JDoctestEngine
All Implemented Interfaces:
org.junit.platform.engine.TestEngine

public class JDoctestEngine extends Object implements org.junit.platform.engine.TestEngine
JUnit Platform test engine which runs the doctests of classes annotated with Doctests. It is registered as a service, so it is found automatically whenever JDoctest is on the test classpath. Its engine ID is "jdoctest".

Each annotated class becomes a container, with one test for each of the @doc.test tags in its documentation and the documentation of its members (and of any nested classes which are not annotated themselves). The tests of a class are run together, by running javadoc on the class's source file; a doctest marked (EXPECT FAIL) which fails is reported as aborted. The engine handles class, package, classpath root and module selectors, so annotated classes are found however the build tool or IDE asks for them. Since the annotation marks the classes to test explicitly, class name patterns (such as the default "*Test" patterns of the console launcher and @Suite) are ignored, but package name filters are honored.

  • Field Details

    • ENGINE_ID

      public static final String ENGINE_ID
      The ID of this test engine.
      See Also:
    • SRC_ROOT_PARAMETER

      public static final String SRC_ROOT_PARAMETER
      JUnit configuration parameter giving the default source directory for Doctests classes which don't specify one.
      See Also:
  • Constructor Details

    • JDoctestEngine

      public JDoctestEngine()
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface org.junit.platform.engine.TestEngine
    • getGroupId

      public Optional<String> getGroupId()
      Specified by:
      getGroupId in interface org.junit.platform.engine.TestEngine
    • getVersion

      public Optional<String> getVersion()
      Specified by:
      getVersion in interface org.junit.platform.engine.TestEngine
    • discover

      public org.junit.platform.engine.TestDescriptor discover(org.junit.platform.engine.EngineDiscoveryRequest request, org.junit.platform.engine.UniqueId uniqueId)
      Specified by:
      discover in interface org.junit.platform.engine.TestEngine
    • execute

      public void execute(org.junit.platform.engine.ExecutionRequest request)
      Specified by:
      execute in interface org.junit.platform.engine.TestEngine