Class JUnitTestRunner
- All Implemented Interfaces:
Generator, Renamable, ResourceProvider
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:
-
Request compilation classpath resources from the test project's dependencies with
Intent.Consume,Intent.Expose, andIntent.Supply. This makes the resources available that are used for compiling test classes as well as the compiled test classes. -
If the project implements
MergedTestProject, get theProject.parentProject(), request compilation class path resources from its dependencies withIntent.Consume,Intent.Expose, andIntent.Supplyand 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 withIntent.Consumeon 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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoProvide(ResourceRequest<T> requested) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.Ignore failed tests.Methods inherited from class AbstractGenerator
cleanup, name, newResource, project, toStringMethods inherited from class AbstractProvider
context, name, of, rename, vavrStream
-
Constructor Details
-
JUnitTestRunner
Initializes a new test runner.- Parameters:
project- the project
-
-
Method Details
-
ignoreFailed
Ignore failed tests. If invoked, the test runner does not set the faulty flag of the test results if a test has failed.- Returns:
- the junit test runner
-
doProvide
Description copied from class:AbstractProviderInvoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
requested- the requested- Returns:
- the stream
-