How to specify @category in test problem in gradle?

I would like to know if I can specify the @category task in the gradle test task. So, I can run integration units and regular junit tests separately .

I know that there is currently no explicit support for @category in gradle , and I'm looking for a workaround for this limitation.

A direct approach is to define test samples for different categories of tests, for example How to run all tests that belong to a certain category in JUnit 4 . I would prefer to specify @category in my gradle script.

+5
source share
2 answers

Support for including or excluding categories is included in gradle:

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

: http://www.gradle.org/docs/current/userguide/java_plugin.html#test_grouping

+18

All Articles