2016-09-15 88 views
1

我想運行使用由Serenity-BDD框架提供的'WithTagValuesOf'註釋的特定junit測試。如何使用SerenityRunner和Gradle運行使用'WithTagValuesOf'註釋的特定測試

基礎上寧靜的教程,我能找到相同的Maven作爲:

mvn clean verify -Dtags="release:sprint-2" 

但我試圖找到搖籃類似的方法。對於前:以上

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 

有人可以幫我這個?

回答

1

我能夠儘快找到答案,因爲我張貼了這個問題(我的壞)

我做了一個調整,以提供對JBehave實施類似的問題的解決方案。感謝肖恩博伊爾的參考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" 
我的測試
相關問題