我有以下代码。我想让它与环境和浏览器的所有组合一起运行多次。我不断收到错误,我认为我的结构有问题。
有人可以提供一些有关如何处理此问题的见解吗?
def enviromentList = [ "AZET" : "www.azet.sk", "GOOGLE" : "www.google.com", "IBM" : "www.ibm.com"]
def browserList = [ "ff", "ie" , "ch" ];
task preTestVerification<< {
enviromentList.each() { key, value ->
browserList.each() {
System.setProperty('env.url', '${key}')
System.setProperty('env.name', '${value}')
System.setProperty('env.browser', '${it}')
println "Launch test for enviroment ${key} on url ${value} with ${it} browser"
tasks.enviromentTest.execute()
//include '**/PreTestVerification.class'
};
};
}
task enviromentTest(type : Test) {
include '**/PreTestVerification.class'
def envBrowser = System.properties['env.browser']
def envName = System.properties['env.name']
reports.junitXml.destination = "$buildDir/test-results/${envName}/${envBrowser}"
reports.html.destination = "$buildDir/test-results/${envName}/${envBrowser}"
}
更新
PS C:\KCDev\KCHead\GradleTest> gradle -q runAllTest
33 tests completed, 30 failed
FAILURE: Build failed with an exception.
*出了什么问题:任务执行失败&#39;:helloch&#39;。&gt;有失败的测试。请参阅以下报告:file:/// C:/KCDev/KCHead/GradleTest/build/reports/tests/index.html
COD
def browserList = [ "ff", "ie" , "ch" ];
task runAllTests << {
println 'running all tests'
}
runAllTests.dependsOn {
browserList.each() {
tasks.create(name: "hello$it", type: Test) << {
println "hello${it}"
include '**/PreTestVerification.class'
}
}
tasks.findAll { task -> task.name.startsWith('hello') }
}