My build.gradle looks like following:
apply plugin: 'eclipse'
apply plugin: 'java'
springVersion = "3.0.6.RELEASE"
//For the dependency update uncomment the following two lines
//env =
//cookie =
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'lib', include: '*.jar')
testCompile "org.springframework:spring-beans:$springVersion",
"org.springframework:spring-core:$springVersion",
"org.springframework:spring-context:$springVersion"
}
test {
systemProperty "environment", "$env"
systemProperty "cookieName", "$cookie"
useTestNG()
ignoreFailures = true
}
task secondTry(type:Test){
onlyIf{
file("build/reports/tests/testng-failed.xml").exists()
}
dependsOn test
testReportDir = file("build/reports/tests/secondTry")
useTestNG(){
suites("build/reports/tests/testng-failed.xml")
}
}
task allTests(dependsOn: tasks.withType(Test))
task wrapper(type: Wrapper) {
gradleVersion = '1.0-milestone-8'
}
To run the testng scritps in bash I execute:
gradle clean allTests -Penv=value1 -Pcookie=value2
And works fine. The problem is when inside eclipse I put the “Refresh all” to refresh the dependences, gives me the error: Could not find property ‘env’ on task ‘:test’.
The solution is to define the two variables empty
env =
cookie =
But the problem with this, is when I run in console. The value I pass does’t override the empty value.
So I have that problem, I need to comment when I run in bash, but uncomment when I use gradle in eclipse.