Run a single test

Is there a way to tell Gradle to run a single test? I have a test that is failing in Gradle but not my IDE and would like to debug it.

When I try this, I get something like:

$ gradlew -Dtest.single=SingleTest :subproject:test … :buildSrc:test FAILED FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:test’. > Could not find matching test for pattern: SingleTest

There is nowadays a flag for this, use ‘gradlew :subproject:test --tests “*SingleTest”’

Yes, there is. You got to use this system property: -Dtest.single. For more information see the Gradle manual.