You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship.

This sample shows how to add additional test types to a JVM project in Gradle. Your project may have many different kinds of tests—​unit tests, integration tests, functional tests, etc. A JVM project in Gradle has a single Test task, but other tasks can be added to represent each of these test types using the Test Suite Plugin.

This sample shows how to adopt an existing sample for use with Test Suites.
Test Suites are an incubating feature, and the details described here may change.

In this sample, we are testing Java projects with JUnit5; however, this applies to other JVM languages as well.

Concretely, we add a convention plugin in buildSrc to share the integration test setup between multiple subprojects:

buildSrc/src/main/groovy/myproject.java-conventions.gradle
plugins {
    id 'java'
}

version = '1.0.2'
group = 'org.gradle.sample'

repositories {
    mavenCentral()
}

testing {
    suites {
        test {
            useJUnitJupiter('5.7.1')
        }

        integrationTest(JvmTestSuite) {
            dependencies {
                implementation project
            }

            targets {
                all {
                    testTask.configure {
                        shouldRunAfter(test)
                    }
                }
            }
        }
    }
}

tasks.named('check') {
    dependsOn(testing.suites.integrationTest)
}
buildSrc/src/main/kotlin/myproject.java-conventions.gradle.kts
plugins {
    java
}

version = "1.0.2"
group = "org.gradle.sample"

repositories {
    mavenCentral()
}

testing {
    suites {
        val test by getting(JvmTestSuite::class) {
            useJUnitJupiter("5.7.1")
        }

        val integrationTest by registering(JvmTestSuite::class) {
            dependencies {
                implementation(project)
            }

            targets {
                all {
                    testTask.configure {
                        shouldRunAfter(test)
                    }
                }
            }
        }
    }
}

tasks.named("check") {
    dependsOn(testing.suites.named("integrationTest"))
}

And apply it in an application project:

application/build.gradle
plugins {
    id 'myproject.java-conventions'
    id 'application'
}

dependencies {
    implementation project(':utilities')
}

application {
    mainClass = 'org.gradle.sample.app.Main'
}
application/build.gradle.kts
plugins {
    id("myproject.java-conventions")
    application
}

dependencies {
    implementation(project(":list"))
    implementation(project(":utilities"))
}

application {
    mainClass.set("org.gradle.sample.app.Main")
}

And in library projects:

utilities/build.gradle
plugins {
    id 'myproject.java-conventions'
    id 'java-library'
}

dependencies {
    api project(':list')
}
utilities/build.gradle.kts
plugins {
    id("myproject.java-conventions")
    `java-library`
}

dependencies {
    api(project(":list"))
}

These additional tests can be executed with the integrationTest task or as part of lifecycle check:

$ ./gradlew check

BUILD SUCCESSFUL
14 actionable tasks: 14 executed