Integration tests not being run

Using Gradle 4.10.2 and JUnit 5.3.1, I’m trying to create integration tests and they are not being executed when I run ‘./gradlew check’. Separately-but-related, if I run check from Intellij I get “Test events were not received”. Below is my build script. The unit and integration tests both are using Jupiter, not JUnit 4.

I’ve scoured StackOverflow et al and tried many variations on the below with no success. Any help appreciated.

buildscript {
    repositories {
        mavenCentral()
    }
}

apply plugin: 'java'

group = 'com.test'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


sourceSets {
    integTest {
        compileClasspath += sourceSets.main.output
        runtimeClasspath += sourceSets.main.output
    }
}

configurations {
    integTestImplementation.extendsFrom implementation
    integTestRuntimeOnly.extendsFrom runtimeOnly
}

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

test {
    useJUnitPlatform()
}

task integrationTest(type: Test) {
    description = 'Run integration tests.'
    check.dependsOn(it)
    group = 'verification'
    testClassesDirs = sourceSets.integTest.output.classesDirs
    classpath = sourceSets.integTest.runtimeClasspath
    shouldRunAfter test
}

Your integrationTest task is not being configured for JUnit 5. The following lines configure only the test task (your unit tests):

You can either also configure the integrationTest task by calling useJUnitPlatform() on it as well or you can handle all Test tasks at once by changing the above to:

tasks.withType(Test) {
    useJUnitPlatform()
}

Thanks James, that was the solution.