Tagged Tests

Categorize and filter tests using the tagged tests.

We'll cover the following

JUnit 5 provides the option to filter and categorize tests. We use the @Tag annotation for this.

It is added on top of the class. We can provide a custom value to this annotation.

The following are some 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.

    • ,
    • (
    • )
    • &
    • |
    • !

Get hands-on with 1400+ tech skills courses.