JUnit 4.8 added experimental support for grouping tests using categories and Gradle has support for including/excluding categories as part of the DSL for configuring testing. This is an example of using the functionality.
There are several possible targets:
gradle test
: run all testsgradle runSlow
: run only tests annotated withSlowTest.class
as the categorygradle runFast
: run only tests annotated withFastTest.class
as the categorygradle runCategories -Pcategories=<categoryList>
: run tests annotated with one or more categories (comma-separated). The category name needs to be the canonical class name; for this example you can specifySlowTest
orFastTest
because they live in the default package