【发布时间】:2021-04-13 22:59:46
【问题描述】:
迁移的设置
Spock 版本 - 2.0-M5-groovy-3.0 jdk 版本 - 11 Maven surefire 插件版本 - 3.0.0-M5 Maven 版本 - 3.8.0
我有一个标记界面和 Spock 2.0 测试,如下所示
`
interface RestTests {}
`
```
@Category(RestTests)
class SimpleTest extends Specification {
def "should should” perform simple test”() {
given:
// …..
}
}
```
当我跑步时
```
./mvnw clean test -Dgroups=com.api.test.categories.RestTests
```
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.6:report (jacoco-report)
【问题讨论】:
-
不要使用 -Dgroups=com.api.test.categories.RestTests 因为它是 JUnit4 相关的特性。先看Surefire的文档maven.apache.org/surefire/maven-surefire-plugin/examples/…和配置参数“groups”的文档maven.apache.org/surefire/maven-surefire-plugin/…
-
如果你想在JUnit5中使用组,你必须阅读maven.apache.org/surefire/maven-surefire-plugin/examples/…“按标签过滤”一章并使用注解@Tag,见howtodoinjava.com/junit5/junit-5-tag-annotation-example
标签: groovy spock maven-surefire-plugin