我想了解我是否可以在gradle测试任务中指定@category。因此,I can run separately integration junits and the normal junit tests

我知道目前有no explicit support for @category in gradle,我正在寻找解决此限制的方法。

直接的方法是为不同的测试类别(例如How to run all tests belonging to a certain Category in JUnit 4)定义测试服。我希望在我的gradle脚本中指定@category。

最佳答案

gradle中包含对包含或排除类别的支持:

test {
  useJUnit {
    includeCategories 'org.gradle.junit.CategoryA'
    excludeCategories 'org.gradle.junit.CategoryB'
  }
}

完整文档:
https://docs.gradle.org/current/userguide/java_testing.html#test_grouping

10-07 19:31
查看更多