I'm migrating an existing Maven and JUnit 5 project where the integration and unit tests are separated into different phases:
*Test.java
unit tests are run on the test phase*IT.java
integration tests are run on the verify phaseHow do I accomplish the same separation with Gradle? It is my understanding that Gradle's check task is the equivalent to Maven's verify.
I ended up using filters to separate the unit and integration tests and to bind the integration tests to the check task:
tasks.named('test') {
useJUnitPlatform {
filter {
includeTestsMatching "*Test"
excludeTestsMatching "*IT"
}
}
}
def integrationTest = tasks.register("integrationTest", Test) {
useJUnitPlatform {
filter {
includeTestsMatching '*IT'
includeTestsMatching 'IT*'
includeTestsMatching '*ITCase'
}
}
}
tasks.named('check') {
dependsOn integrationTest
}