Test class with different environments


(Carsten Paul) #1

Hi,

don’t get it and it drives me grazy…
I’ve setup a project with gradle, spock and geb. Everythings works fine, crated a lot of tests and now I want to start some cross browser testing. Easy, I thought.
So I created two tasks:
task Safari(type: Test) {
systemProperty “geb.env”, “localeSafari”
}

task Chrome(type: Test) {
    systemProperty "geb.env", "localeDesktop"
}

When I run:
./gradlew Safari --tests common.LoginCheck
or
./gradlew Chrome --tests common.LoginCheck

it works as expected. It starts the regarding Browser and tests just this one class.

than I’ve created
task testAll (type:Test, dependsOn: ["Safari",Preformatted text"Chrome"])
this runs all(!) tests, but only on Chrome

and the task:
task testSafari(type:Test, dependsOn: Safari)
opens Safari but run all tests and ignores the --tests

Guess that there is a point where I miss some understanding of gradle, but don’t get the point. Invested hours in trial and error, searching and reading, but don’t get it.
Someone here who can help? Would appreciate it very much.

tnx

Carsten


(Chris Doré) #2

Task-specific command line options only apply to the task they immediately follow, they are not global. In the case of ./gradlew testSafari --tests ... the specified --tests option configures the testSafari task but the dependency Safari is executed without modification.


(Carsten Paul) #3

Thanks Chris! This explains the behavior and why it can’t work as expected.
but now I have no idea how to go further :frowning: