Class JUnitTestRunner

All Implemented Interfaces:
Generator, Renamable, ResourceProvider

public class JUnitTestRunner extends AbstractGenerator

A Generator for TestResults using the JUnit platform. The runner assumes that it is configured as Generator for a test project. The class path for running the tests is build as follows:

  1. Request compilation classpath resources from the test project's dependencies with Intent.Consume, Intent.Expose, and Intent.Supply. This makes the resources available that are used for compiling test classes as well as the compiled test classes.

  2. If the project implements MergedTestProject, get the Project.parentProject(), request compilation class path resources from its dependencies with Intent.Consume, Intent.Expose, and Intent.Supply and add them to the class path. This makes the resources available that are used for compiling the classes under test as well as the classes under test. Note that this is partially redundant, because test projects most likely have a dependency with Intent.Consume on the project under test anyway in order to compile the test classes. This dependency does not, however, provide all resources that are required to test the project under test.

The runner then requests all resources of type ClassTree from the test projects's Generator's and passes them to JUnit's test class detector.

Libraries for compiling the tests and a test engine of your choice must be provided explicitly to the runner's project as dependencies, e.g. as:

project.dependency(Consume, new MvnRepoLookup()
    .bom("org.junit:junit-bom:5.12.2")
    .resolve("org.junit.jupiter:junit-jupiter-api")
    .resolve(Scope.Runtime,
       "org.junit.jupiter:junit-jupiter-engine"));

In order to track the execution of the each test, you can enable level fine logging for this class. Level finer will also provide information about the class paths.