How to execute control cases of cucumber in parallel using the Grid?

After doing a lot of research on how to run Cucumber test cases in parallel, I found the following very useful article on this subject:

https://www.opencredo.com/2013/07/02/running-cucumber-jvm-tests-in-parallel/

The article has pretty good information to get you started with a multi-threaded environment, including some code that you can download from Github.

https://github.com/tristanmccarthy/Cucumber-JVM-Parallel

If I understand the article correctly, the driver must be configured to work with the grid, which allows you to run several test cases on multiple devices. After some testing with code using a chrome rib, it works as described in the article. However, once it is configured to work with the grid, test cases are no longer run in parallel. Instead, they are executed sequentially.

I currently have a Grid configured to have 1 hub and 2 nodes. Each node can have a maximum of 2 sessions at any given time.

Note. Without Cucumber, I can successfully deploy multiple test cases on multiple devices. So I don’t think the problem is with my grid setup.

Here is sample web driver related code:

static { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setJavascriptEnabled(true); capabilities.setBrowserName("chrome"); capabilities.setPlatform(Platform.ANY); try { REAL_DRIVER = new RemoteWebDriver(new URL("http://xxx.xxx.xxx.xxx:4444/wd/hub"), capabilities); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } REAL_DRIVER.manage().timeouts().pageLoadTimeout(3000, TimeUnit.SECONDS); REAL_DRIVER.manage().window().maximize(); Runtime.getRuntime().addShutdownHook(CLOSE_THREAD); } public SharedDriver() { super(REAL_DRIVER); } @Override public void close() { if (Thread.currentThread() != CLOSE_THREAD) { throw new UnsupportedOperationException( "You shouldn't close this WebDriver. It shared and will close when the JVM exits."); } super.close(); } 

I suspect that if you use more than one type of browser, you should be able to run test cases on multiple devices (1 browser per device), but in my case I use the Chrome driver. Does anyone know what can prevent the spread of test cases on multiple devices or better understand how the Grid works with cucumber? Please share any articles or information related to this issue.

+5
source share
1 answer

The grid does nothing about splitting tasks. It took me a while (and a lot of scotch) to finally understand that all the Grid somewhere removes the work and passes it to an accessible node.

You need a test runner that will split your performance / script tests into different pieces to go to the Grid. Unfortunately, the Cucumber runner does not. There are several ways to separate these tests into separate tasks in order to move to the Grid.

This OpenCredo blog points to a new post that uses Maven . Be sure to check it out!

Someone mentioned TestNG. I have not used it, so I can not comment on it.

You can separate your capabilities / scenarios yourself and transfer tasks separately to your grid by performing different test passes - this is cumbersome for long-term maintainability, but it is a quick start.

We wrote a small runner that scans scripts and dynamically transfers them to the grid. I can’t share the code, because it works, and I'm at my hotel ...

Keep in mind: you have to manage concurrency dependencies and issues. I hope you structure the tests so that there are no dependencies between them. concurrency is another matter. We have some code that opens unlocked resources for tests (think users, data sets, etc.)

Good luck

+2
source

Source: https://habr.com/ru/post/1238985/


All Articles