Integration Testing with JUnit 5

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?

You need to include the JUnit 5 dependencies yourself. In order for the unit tests to work, you should already have something along the lines of:

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
}

Either add the dependencies to the configurations created for the itest source set:

dependencies {
    itestImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
    itestRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
}

or make those itest configurations extend from the equivalent test configurations, or add the test configurations as dependencies of the itest configuration.

That was the missing piece.
Thank You!