Hello everyone,
As the summary describes there is a big issue while trying to execute parallel execution along with Spock and Geb.
As you know it Spock team introduced recently this feature:
https://spockframework.org/spock/docs/2.0-M4/parallel_execution.html with nice execution modes. The problem is that when you want to use that feature along with GEB it will not work properly. This is my setup:
Spock Config file contains: runner {
parallel {
enabled true
}
}
Geb Config file contains:
cacheDriverPerThread = true
System.setProperty("webdriver.chrome.driver", "path to chromedriver.exe")
driver = {new ChromeDriver()}
Test class is a child of a custom test manager class that extends GebReportingSpec
Note: In the custom test manager class I used the go baseUrl to open a specific page.
CustomPage (e.g LoginPage) class is a child of a class manager that extends Page from Geb
Now everything works as expected while I try to execute a test or multiple tests from a class in the traditional way (with the parallel { enabled false }) however when I enable the parallel option from the config file the spock tests starts in parallel BUT the GEB does not initiate the new browser instances, all the tests are executed simultaneously on the same instance one and only leaving the new instances empty (having in the url: data;) or with the base url mentioned in the GebConfig!
If you have cacheDriverPerThread set on false you will have the same behavior but without opening new browser instances.
The big question is: Was anyone able to execute parallel tests using Spock and GEB without having this issue?
I tried on several devices (different configurations) with several parameters and configs, in the end I had the same behavior, multiple browser instances were opened but only one of them received the tests and the execution of tests was at the same time for all of them. (one test tring to press on the Login button, another trying to write something, another trying to delete something) - all this actions at the same time.
I've verified all the subjects related to this from the stackoverflow and the most important containing similar subject was this:
https://stackoverflow.com/questions/41897862/running-spock-tests-in-parallel
I've even wrote an email to Leonard who does some work for Spock but he suggested me to write the issue on stackoverflow and maybe erdi from GEB will have a look.
Well I don't want to give up using this combination and I really want to have my tests running in parallel not via gradle but via spock along with GEB :)
Note: If I use gradle task to execute them in parallel it will work BUT the execution is performed per class not per feature, so you will have class tests running in parallel (tests from a class will run one after another) not tests from a class running in parallel. And you must have the feature of parallel set on false in the SpockConfig file otherwise you will run test class in parallel and also tests from a class in parallel but with the issue that I've already mentioned.
The desired behavior is to be able to execute class tests in parallel AND tests from a class in parallel but the initialization should be performed for all new browser instances.
Please have a look and please let me know if this setup works for you guys :)
Thanks :)