SimitTomar / wdio-cucumber-parallel-execution

A WebdriverIO capability for running Cucumber scenarios in parallel.
25 stars 10 forks source link

Queries on parallel execution implementation #16

Closed Anudbeg-clarivate closed 3 years ago

Anudbeg-clarivate commented 3 years ago

Hi Simit, I have 420 ui scenarios. Currently execution time is 4 hours for all the tests. So I need to implement the parallel execution method in our framework. 1) We are using files such world.js for which acts like a wdio Testrunner file 2) Using helpers.js file for maintaining the common methods which we call in our scripts 3) index.js file is our main file 4) build.gradle file is to run our scripts 5) Now how can I implement this parallel execution method in these files or doI have to add your 4 files as a separate files? If yes then what needs to be modified inside the files? 6) Do we have to add all the 4 files in our framework featureFileSplitter, performSetup, getConsolidatedData and index.js in order to run the scripts in parallel ? Please provide the solutions. I have attached few screenshots of my framework structure. Please let me know if you need anything else from my end. Thanks other_files

parallelExecution

runtime_files

from my end.

Anudbeg-clarivate commented 3 years ago

Also in the screenshot, I could see you have used SauceLabs. Do we need SauceLabs as well for this implementation or not needed? And how does it work for test cases where we have Scenario Outline with Examples keyword?

SimitTomar commented 3 years ago

Hi Anudbeg,

Conceptually, the wdio-cucumber-parallel-execution module is splitting your feature files into multiple feature files, storing it in a temporary folder and then feeding it to webdriverIO's test runner. There is an attribute 'maxInstances' which when put in the Test Runner file, allows parallel execution. The only difference between webdriverIO's default parallel behaviour is that it does not parallelise the tests written in the same feature file whereas wdio-cucumber-parallel-execution is creating multiple feature files out of a single feature file as well (1 test in each feature file), parallelism of tests within the same feature file is possible.

From the documentation of webdriverIO, it appears that we would need Test Runner for parallel execution as the 'maxInstances' attribute is available within it, haven't tried without it. It might be worth checking with the webdriverIO community.

You don't need to add the 4 files, you simply need to install the wdio-cucumber-parallel-execution module and then call it the way it has been called in its documentation. Also, Saucelabs is just shown as an example, it's not required by the module.

Please let me know in case you have any other queries.

Thanks, Simit

Anudbeg-clarivate commented 3 years ago

Hi Simit, thanks for the detailed description. I have few more queries on your reply: 1) So post implementation, do I need to run my scripts using 'maxInstances' attribute in the TestRunner file? If yes then how many threads we can define in 'maxInstances' attribute ? Can we run with 9 instances or more than that? Does it depends on the system's memory or can we use VM as well to run the scripts? 2) In our framework we do not use TestRunner file. We have made use of world.js files. Could you provide the lines of code for TestRunner file and what we need to pass? 3) Where do I have to use the set up code and 'Get Consolidated JSON Report Array' code in our framework? It is mentioned as wdio.conf.js but in my framework I am little confused where exactly to use this code. Please help 4) fs.writeFileSync(jsonFile, JSON.stringify(consolidatedJsonArray)) -> It is asking me to create a method for writeFileSync. I am getting error at present. What shall I do here? 5) We are running our tests only in Chrome browser. We have defined the configuration for chrome in chromeDriver.js file. Can we add this line maxInstances: 10, before capabilities. Will it work ? This is how it is configured const wdio = require('webdriverio'); const path = require('path'); const fs = require('fs-extra');

/**

"scripts": { "test": "npx selenium-standalone install & npx selenium-standalone start | node index.js -dt @smokescenarios | --parallel=true"} 7) If my feature files are inside a directory and that directory is inside another directory, will it read the feature file from that location? Eg: features directory -> Test directory -> myfiles1.feature, myfiles2.feature....

Anudbeg-clarivate commented 3 years ago

8) Does running the scripts will launch multiple browsers and execute as defined in maxInstances attribute or it will run in background in headless mode?

SimitTomar commented 3 years ago

Hi Anudbeg,

Most of these questions are independent of the wdio-cucumber-parallel-execution, would suggest you to go through the official documentation of webdriverIO to know more the configuration and how parallel execution works (specifically the Testrunner - https://webdriver.io/docs/clioptions https://webdriver.io/docs/clioptions)

Additionally, you may also refer to a webdriverIO boilerplate that I have created, it shows the usage of this module. Code for calling this module is mentioned in wdio.conf.js file and you need to set the ‘parallel’ module flag to true in the package.json file. Reference URL: https://github.com/SimitTomar/webdriverio-cucumber-pom-boilerplate https://github.com/SimitTomar/webdriverio-cucumber-pom-boilerplate

I think you might want to first try running the default parallel execution of webdriverio and once that works, implement this module. Number of browsers you can run will depend on the number you pass in the maxInstances attribute which should be driven by your machine configuration (generally 8 is a good number). Also, it will execute the scripts in the browser which you have provided in your capabilities.

Thanks Simit

On 18-Mar-2021, at 4:30 PM, Anudbeg-clarivate @.***> wrote:

Does running the scripts will launch multiple browsers and execute as defined in maxInstances attribute or it will run in background in headless mode? — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/SimitTomar/wdio-cucumber-parallel-execution/issues/16#issuecomment-801828908, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTRQXIY4R3SEEGZIUNIQWDTEHMOVANCNFSM4ZI4C7PA.

Anudbeg-clarivate commented 3 years ago

Hi Simit, In IntelliJ, I am getting below two errors 1) for wdioParallel.performSetup function . It says "Promise returned from performSetup is ignored" 2) fs.writeFileSync - It says Unresolved function or method writeFileSync() Rest of the code is fine. How to fix this ? 3) specs: [ featureFilePath ], Do we have to pass the feature files path under specs attribute? I have multiple feature files in separate directories. How do I pass then?