I am using Gradle 5.3 to manage the builds for a multi-module Java project. JUnit5 is currently being used to handle unit testing, and I now need to specify and run integration tests in my CI pipelines. I have created a new SourceSet called itest
to keep integration tests separate from unit tests, and a new task called itest
which I can call from Jenkins to run just the integration tests. I have included useJUnitPlatform()
in that task, and while everything runs as expected, JUnit is not added to the classpath so I get build failures:
<pathToClass>\SimpleTest.java:9: error: package org.junit.jupiter.api does not exist
import org.junit.jupiter.api.*;
^
Eventually, I want to add other sets for performance tests (ptest), load tests (ltest) and security tests (stest). It would be easier to manage the test code it was stored in their respective directories as opposed to using tags.
What is the recommended way to define an additional set of sources and a task for testing to ensure JUnit5 is properly included in the classpath?