问题描述
迁移设置
Spock 版本 - 2.0-M5-groovy-3.0 jdk 版本 - 11 Maven surefire 插件版本 - 3.0.0-M5 Maven 版本 - 3.8.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)
解决方法
@Category
是一个 junit4
功能,Spock 2.0 是 JUnit 平台上的一个合适的 TestEngine
,请查看 Spock 文档的 Include and Exclude。提示:这是一个常规文件,因此您可以根据需要添加逻辑。
如果您想在 JUnit5 中使用组,您必须阅读https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html“按标签过滤”一章并使用注释 @Tag,请参阅 https://howtodoinjava.com/junit5/junit-5-tag-annotation-example/ >