Run JUnit with Gradle of only specific intersection of categories

I’m migrating a Java project from been built and test with Maven to be built and test with Gradle.

When we run tests we are using maven-failsafe-plugin which is able to accept a logical expression of which categories to include and exclude. For example it can accept the expression com.mycomp.UITest and com.mycomp.QuickTest and it will only run tests which annotated with @Category({UITest, QuickTest}).

In Gradle I can pass multiple category classes but it looks like it is using an OR and not an AND.

It looks from Gradle source code CategoryFilter.java that it’s enough that one category will match to run the test.

How can I run only test method which have ALL of the test categories?

UPDATE1
I’ve dug dipper into Maven source code and it looks like Maven plugin has rich expression language with AND, OR, and NOT operations.

1 Like