我正在尝试运行一组特定的junit测试,这些测试使用Serenity-BDD框架提供的“WithTagValuesOf”进行了注释。
根据Serenity教程,我可以为Maven找到与以下相同的东西:
mvn clean verify -Dtags="release:sprint-2"
但是我正在尝试为Gradle寻找类似的方法。例如:
gradle clean test --tests -Dtags="Test-Type:Smoke" aggregate
上面给了我以下错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> No tests found for given includes: [tags=Test-Type:Smoke]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
有人可以帮我这个忙吗?
最佳答案
发布此问题后,我就能找到答案(我的错)
我对提供给JBehave实现类似问题的解决方案进行了调整。感谢Shawn Boyle提供引用https://groups.google.com/d/msg/thucydides-users/IFwX64zuFSw/vC_43Nl_C84J
这是我添加到构建文件中的代码。
build.gradle:
task copyPropsFile << {
if(!project.hasProperty('environment')){
ext.environment = 'dev'
}
copy{
from '../conf/' + environment + '/properties/serenity.properties'
into projectDir
}
if (project.hasProperty('tags')) {
println "JUnit tags set to: $tags"
ant.propertyfile(file: "$projectDir/serenity.properties") {
entry(key: "tags", value: "$tags")
}
}
}
// Hook into the gradle processTestResources task to execute the copyPropsFile custom task
processTestResources{
doFirst{
copyPropsFile.execute()
}
}
最后,我使用
gradle clean test aggregate -Ptags="Test-Type:Smoke"
关于gradle - 如何使用SerenityRunner和Gradle运行带有 'WithTagValuesOf'注释的特定测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39515033/