Gradle: how to exclude some tests?

Credit: This answer is inspired by JB Nizet’s answer. It is posted because it is more direct to my question.

To run the unit tests only, create a new task like this:

task unitTest( type: Test ) {
    exclude '**/cucumber/**'
}

This way we have:
run all tests: ./gradlew test
run all unit tests: ./gradlew unitTest
run all functional tests: ./gradlew test -Dtest.single=cucumber/**/

Leave a Comment