2.8. Tagging and Filtering
Test classes and methods can be tagged via the @Tag
annotation. Those tags can later be used to filter test discovery and execution.
See also: Tag Expressions |
2.8.1. Syntax Rules for Tags
A tag must not be
null
or blank.A trimmed tag must not contain whitespace.
A trimmed tag must not contain ISO control characters.
A trimmed tag must not contain any of the following reserved characters.
,
: comma(
: left parenthesis)
: right parenthesis&
: ampersand|
: vertical bar!
: exclamation point
In the above context, “trimmed” means that leading and trailing whitespace characters have been removed. |
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@Tag("fast")
@Tag("model")
class TaggingDemo {
@Test
@Tag("taxes")
void testingTaxCalculation() {
}
}
See Meta-Annotations and Composed Annotations for examples demonstrating how to create custom annotations for tags. |