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

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 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 **/*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.

References

  1. Gradle display test results in console
  2. Gradle – How to skip unit test
  3. Gradle Test documentation

上一篇: Java How to join Arrays
下一篇: Debian Show apt-get package version
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号