是否可以 select 测试用 JUnit5/Gradle 中的标签组合注释?

Is it possible to select tests annotated with combination of tags in JUnit5/Gradle?

假设测试被标记为 "slow","fast","ui","api"(以及其他)。所以有些测试可能会被标记为 "fast" 和 "api",而有些测试可能会被标记为 "fast" 和 "ui"

如何 select 测试同时标记 "fast" 和 "api"?

includeTags: "fast","api" 

将运行所有快速测试(甚至"ui")和所有"api"测试(甚至"slow")。

如果有这样的东西就好了:

includeAllTheTags: "fast","api" 

为此。

还有其他解决方案吗?

这记录在 the JUnit documentation 中:

includeTags("fast & api")

标记表达式来拯救!

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

https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions

中查找更多详细信息和样本

对于Gradle,它可以读成

test {
    useJUnitPlatform {
        includeTags 'fast & api'
    }
}

来源:https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle