当前位置: 首页 > 文档资料 > JUnit 5 用户指南 >

1.2.4.6. Tag Expressions

优质
小牛编辑
129浏览
2023-12-01

Tag expressions are boolean expressions with the operators !, & and |. In addition, ( and ) can be used to adjust for operator precedence.

Two special expressions are supported, any() and none(), which select all tests with any tags at all, and all tests without any tags, respectively. These special expressions may be combined with other expressions just like normal tags.

Table 2. Operators (in descending order of precedence)
OperatorMeaningAssociativity
!notright
&andleft
|orleft

If you are tagging your tests across multiple dimensions, tag expressions help you to select which tests to execute. When tagging by test type (e.g., micro, integration, end-to-end) and feature (e.g., product, catalog, shipping), the following tag expressions can be useful.

Tag ExpressionSelection
productall tests for product
catalog | shippingall tests for catalog plus all tests for shipping
catalog & shippingall tests for the intersection between catalog and shipping
product & !end-to-endall tests for product, but not the end-to-end tests
(micro | integration) & (product | shipping)all micro or integration tests for product or shipping