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.build.gradle
test {
exclude 'com/mkyong/example/**'
}
In this example, test class
TestExample.class
will be excluded.Note
The package is defined with backslash, not period or dot (.), if you define
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.build.gradle
test {
exclude '**/*Controller*'
}
In this example, Test class
TestController.class
will be excluded.Note
The RegEx pattern is case sensitive, if you define a lower case ‘c’ , like
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.build.gradle
test {
exclude '**/TestController.class'
}
or, use the exact location.
build.gradle
test {
exclude 'com/mkyong/helloworld/TestController.class'
}
Done.
No comments:
Post a Comment