Tagging tests only works with Maven Surefire/Failsafe integration at the moment.
Want to run just a sub-set of your tests? No problem. Simply decorate your tests with one or more tags:
with(tags("smoke", "fast")).
it("returns -1", () -> {
// ...
});
Tags can be specified when running Cuppa via Maven using the tags
property.
For example, to run only the tests with the tag smoke
:
mvn -Dtags=smoke test
Alternatively you can run all tests which are not tagged with one or more specific tags.
For example, to run all tests except tests tagged with slow
:
mvn -DexcludedTags=slow test
If you want more flexibility you can use an expression.
For example, to run all the tests with fast
tag or with smoke
and ui
tags excluding all slow
tags :
mvn -DgroupsExpression="and(or(fast,and(smoke,ui)),not(slow))"
When running with a combination of TestNG or JUnit along side Cuppa, you can use the TestNG/JUnit way of specifying/excluding groups so that you can run a sub-set of tests across both TestNG/JUnit and Cuppa.
It’s important to note that you cannot use -Dgroups=
and -Dtags=
, -DexcludedGroups=
and -DexcludedTags=
or -DgroupsExpression
and -DtagsExpression
at the same time.
It’s important to note that you cannot if you use the expression you cannot use tags/groups or excludedTags/excludedGroups
Similarly you can tag all tests within a describe
or when
block:
with(tags("smoke")).
when("it is empty", () -> {
it("returns -1", () -> {
// ...
});
});