Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (53 sloc) 1.85 KB
title
Tagging Tests

{::options parse_block_html="true" /}

#### Note

Tagging tests only works with Maven Surefire/Failsafe integration at the moment.

Tagging a Single Test

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))"
#### Note

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.

#### Note 2

It's important to note that you cannot if you use the expression you cannot use tags/groups or excludedTags/excludedGroups

Tagging a Block of Tests

Similarly you can tag all tests within a describe or when block:

with(tags("smoke")).
when("it is empty", () -> {
    it("returns -1", () -> {
        // ...
    });
});