Test not being excluded

Hi, I’m trying to exclude some test from my build. I don’t want to remove them at this time, just exclude them for the time being and enable them once someone fix a bug.
I tried adding the exclude in the test configuration inside the gradle.build, to no effect.

test {
    maxParallelForks = 1
    jvmArgs = ["-Dlogback.configurationFile=logback-quiet.xml"]
    exclude '**AuthE2EServerTest*'

I tried several wildcards, like **/AuthE2EServerTest, **/AuthE2EServerTest*, **/*AuthE2EServerTest, src/test/auth/AuthE2EServerTest*, auth/AuthE2EServerTest, **/AuthE2EServerTest*,

I’m using scalatest and scoverage plugins, ans this is the output of ./gradlew -v

Gradle 4.4

Build time:   2017-12-06 09:05:06 UTC
Revision:     cf7821a6f79f8e2a598df21780e3ff7ce8db2b82

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM:          1.8.0_201 (Oracle Corporation 25.201-b09)
OS:           Mac OS X 10.14.5 x86_64

ScalaTest plugin version:

scalaTest = ‘org.scalatest:scalatest_2.12:3.0.5’

Scoverage plugin version:

scoverage ‘org.scoverage:scalac-scoverage-plugin_2.12:1.3.0’

Am I missing something?

I noticed some (maybe subtle?) differences between the wildcard examples you gave, compared to the ones given in Gradle’s Test User Guide and also the ones given by the always-helpful Mkyong:

  1. None of your examples show that you tried enclosing the name of the test in asterisks on both sides of the name: **/*YourTest*
  2. None of your examples show that you tried appending .class to the name when you use the package qualifier: auth/AuthE2EServerTest.class
  3. None of your examples show that you tried the package-wide pattern: auth/**

I haven’t tried any of those build.gradle exclusion approaches myself, mind you :slight_smile: So I’d be grateful — as will others who will have a similar need in the future — if you get back to us here with whatever solution you get working for you. Please?

Sorry, I must forgot, but I did try **/*MyTest*, I’ll try the package qualifier.

Once I figure out how to exclude the test, I’ll post a follow up for sure.


By the way, I don’t know from scalatest, but I would expect for most XUnit-type unit test frameworks to have something akin to JUnit’s @Ignore annotation.

In JUnit (and NUnit, if I remember correctly) you can ignore tests at both the class and method levels. That’s another option you might have.

I’m curious. What have you figured out so far?

I’m in the progress of upgrading to gradle 5.4.1, scalatest 0.25 and scoverage 3.1.
Seems I’m using versions that are too old, and probably most documentation and examples I found so far, are for more recent versions.
I’ve some estrange dependencies, that are breaking my build.

I really hope that will fix the issues, and let me exclude test

So, after updating everything, I’m now running on gradle 5.4.1, scalatest 0.25 and scoverage 3.1.2

None of the exclude configurations work, the only thing that I got working, is the ignore, which works fine on scalatest.

For Scoverage, the exclude configuration does work, but since it excludes the class and not the test, my code coverage goes up (and it’s the opposite of what I was looking for).

This is my new scoverage config:

scoverage {
minimumRate = 0.99
excludedPackages = [ ‘package’ ]

1 Like

Hey Cool. It’s good that you found a solution. Thanks for sharing :+1: