JUnit Categories - is it possible to find relevant tests under a 'parent' regardless of sub-directory


(Lee) #1

I’d like to be able to execute tests with Gradle based on a category associated with tests.

Example: execute only tests with a Category of ‘CategoryA’

In looking at using JUnit Categories with Gradle, it appears that one would have to put the then entire package reference with Category in the ‘includeCategories’ statement.

Example:
test {
useJUnit {
includeCategories ‘org.gradle.login.CategoryA’
}
}

We will have tests with the same Category spread across multiple directories.

Examples:

  • org.gradle.login > test 1 annotated with ‘CategoryA’
  • org.gradle.square > test 2 annotated with ‘CategoryA’
  • org.gradle.circle > test 3 annotated with ‘CategoryA’
  • org.gradle.nnnnn > test 4 annotated with ‘CategoryA’

For the example above, would there be a way enter a reference to a parent package (org.gradle), followed by a wildcard pattern, followed by a Category so that it will look for all tests regardless of directory and execute them?

Example:
test {
useJUnit {
includeCategories ‘org.gradle.**.CategoryA’
}
}

If there is no way to do this with JUnit, are there any other recommendations that may accomplish this?


(Lee) #2

Just giving this a bump to see if anyone may have any feedback.