I haven't been able to get the "tests" parameter of gradle 4.4 and now 4.4.1 to filter JUnit (5.0.2) tests. The following command runs every test no matter what I change "bogus" to:
gradle test --tests bogus
I would expect this command to fail since there is no test called "bogus." I have also tried referring to a legitimate test, and every test is run regardless. My build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2'
}
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'maven'
apply plugin: 'org.junit.platform.gradle.plugin'
compileJava {
options.compilerArgs += "-Xlint:unchecked"
}
repositories {
mavenCentral()
}
dependencies {
testCompile('org.junit.jupiter:junit-jupiter-api:5.0.1')
testCompile('org.apiguardian:apiguardian-api:1.0.0')
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.0.1')
}
// Define the main class for the application
mainClassName = 'CMS'
jar {
manifest {
attributes 'Implementation-Title': 'CMS',
'Main-Class': 'com.brandli.cms.CMS'
}
}
junitPlatform {
filters {
includeClassNamePattern '.*'
}
}
junitPlatformTest {
enableAssertions = true
}
tasks.withType(Test) {
testLogging {
exceptionFormat = 'full'
showStackTraces = true
}
}
task buildCtags(type: Exec, dependsOn: classes) {
workingDir 'build'
commandLine 'ctags', '-R', '-f', 'java.tags', '../src/main/java',
'../src/test/java'
}
assemble.dependsOn buildCtags
I have tried taking out the junitPlatform, the junitPlatformTest, and the tasks.withType(test) clauses with no change.
My tests only contain the @Test annotation for each method: no other annotations.
Anyone able to get this to work?
EDIT:
This is not a duplicate of How to run only one test class on gradle. The answer to that question recommended using the gradle option that I cannot now get to work, or even be recognized at all.