gradle - 如何使用SerenityRunner和Gradle运行带有 'WithTagValuesOf'注释的特定测试

标签 gradle serenity-bdd

我正在尝试运行一组特定的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/

相关文章:

jetty - 无法让 jettyRun 在 Gradle 中工作

intellij-idea - 通过Gradle构建获取oozie-client依赖性

java - 无法在 Spring Boot 上构建可执行 JAR

java - Restful 剧本模式-上传文件

java - 使用 JUnit 在注释中创建注释

java - 如何在失败时重新启动 Serenity 场景并在成功结果的情况下在报告中获得成功

android - Play 商店显示 0 个具有相同代码的受支持设备

android - ANDROID STUDIO BUILD错误org.gradle.internal.UncheckedException:java.util.concurrent.ExecutionException

java - cucumber 步骤无法识别字符串

selenium - 如何与 gradle 并行运行 Serenity Web 测试?