Gradle How to exclude some tests
In this tutorial, we will show you a few examples to exclude some tests in Gradle. Review the following two unit test classes
1. com.mkyong.helloworld.TestController.class 2. com.mkyong.example.TestExample.class
1. Package level RegEx
1. Any test classes from this package com/mkyong/example/ will be excluded.
test { exclude 'com/mkyong/example/**'
In this example, test class TestExample.class will be excluded.
The package is defined with backslash, not period or dot (.), if you define com.mkyong.example.**, NO test classes will be excluded.
2. Class name RegEx
Any test classes from any package with this class name pattern *Controller* will be excluded.
test { exclude '**/*Controller*'
In this example, Test class TestController.class will be excluded.
The RegEx pattern is case sensitive, if you define a lower case ‘c’ , like **/*controller*, NO test classes will be excluded.
3. Single Test
In this example, only the TestController.class will be excluded.
test { exclude '**/TestController.class'
or, use the exact location.
test { exclude 'com/mkyong/helloworld/TestController.class'
Done.
References