From fcdc93070ed547cd66e9965190730b887de60ef9 Mon Sep 17 00:00:00 2001 From: AutomatedTester Date: Wed, 6 Mar 2024 12:46:05 +0000 Subject: [PATCH 1/4] allow parallel envs --- lib/runner/cli/cli.js | 4 ++++ lib/runner/test-runners/cucumber.js | 4 ++++ .../testCucumberTestsInParallel.js | 3 ++- test/extra/cucumber-config-parallel.js | 15 ++++++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/runner/cli/cli.js b/lib/runner/cli/cli.js index 5d14ef2cd2..548e397711 100644 --- a/lib/runner/cli/cli.js +++ b/lib/runner/cli/cli.js @@ -450,6 +450,10 @@ class CliRunner { } isTestWorkersEnabled() { + if (this.testRunner.supportsTestWorkers === false) { + return false; + } + const testWorkers = this.test_settings.testWorkersEnabled && !singleSourceFile(this.argv); if (!testWorkers) { diff --git a/lib/runner/test-runners/cucumber.js b/lib/runner/test-runners/cucumber.js index 6a505a03f8..c464e55914 100644 --- a/lib/runner/test-runners/cucumber.js +++ b/lib/runner/test-runners/cucumber.js @@ -246,6 +246,10 @@ class CucumberSuite extends TestSuite { class CucumberRunnner extends Runner { get supportsConcurrency() { + return true; + } + + get supportsTestWorkers() { return false; } diff --git a/test/cucumber-integration-tests/testCucumberTestsInParallel.js b/test/cucumber-integration-tests/testCucumberTestsInParallel.js index ca6a7ae34f..39a5e0b0a4 100644 --- a/test/cucumber-integration-tests/testCucumberTestsInParallel.js +++ b/test/cucumber-integration-tests/testCucumberTestsInParallel.js @@ -41,7 +41,7 @@ describe('Cucumber integration - parallel running single formatter', function() }); }); - it('testCucumberSampleTests in parallel with multiple step definition files', function() { + it.only('testCucumberSampleTests in parallel with multiple step definition files', function() { commandMocks.elementText('5cc459b8-36a8-3042-8b4a-258883ea642b', 'xx'); @@ -56,6 +56,7 @@ describe('Cucumber integration - parallel running single formatter', function() parallel: true, verbose: true, timeout: 10, + env: 'chrome,firefox', silent: false, tags: ['not @fail'], format: 'progress', diff --git a/test/extra/cucumber-config-parallel.js b/test/extra/cucumber-config-parallel.js index 302ea4212d..16badba911 100644 --- a/test/extra/cucumber-config-parallel.js +++ b/test/extra/cucumber-config-parallel.js @@ -26,6 +26,19 @@ module.exports = { feature_path: path.join(__dirname, '../cucumber-integration-tests/sample_cucumber_tests/parallel/sample.feature') } }, + + test_settings: { + chrome: { + desiredCapabilities: { + browserName: 'chrome' + } + }, + firefox: { + desiredCapabilities: { + browserName: 'firefox' + } + } + }, output: false, silent: false -} \ No newline at end of file +}; \ No newline at end of file From 31c51e34daecaffd67b400ea849cf61488fdc8ea Mon Sep 17 00:00:00 2001 From: Priyansh Garg Date: Mon, 11 Mar 2024 15:47:07 +0530 Subject: [PATCH 2/4] Remove `.only` from test case. --- test/cucumber-integration-tests/testCucumberTestsInParallel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cucumber-integration-tests/testCucumberTestsInParallel.js b/test/cucumber-integration-tests/testCucumberTestsInParallel.js index 39a5e0b0a4..a04c3cc419 100644 --- a/test/cucumber-integration-tests/testCucumberTestsInParallel.js +++ b/test/cucumber-integration-tests/testCucumberTestsInParallel.js @@ -41,7 +41,7 @@ describe('Cucumber integration - parallel running single formatter', function() }); }); - it.only('testCucumberSampleTests in parallel with multiple step definition files', function() { + it('testCucumberSampleTests in parallel with multiple step definition files', function() { commandMocks.elementText('5cc459b8-36a8-3042-8b4a-258883ea642b', 'xx'); From f5911137caf29a8e0be85090288d9e8351cddeca Mon Sep 17 00:00:00 2001 From: AutomatedTester Date: Thu, 14 Mar 2024 15:00:15 +0000 Subject: [PATCH 3/4] Updated from comments --- lib/runner/cli/cli.js | 8 ++++---- lib/runner/test-runners/cucumber.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/runner/cli/cli.js b/lib/runner/cli/cli.js index 548e397711..5b4e7d5de8 100644 --- a/lib/runner/cli/cli.js +++ b/lib/runner/cli/cli.js @@ -293,7 +293,7 @@ class CliRunner { if (plugins.length > 0) { plugins.forEach((plugin) => { - if (plugin.globals && Utils.isFunction(plugin.globals.registerEventHandlers)){ + if (plugin.globals && Utils.isFunction(plugin.globals.registerEventHandlers)) { plugin.globals.registerEventHandlers(NightwatchEventHub); } }); @@ -450,11 +450,11 @@ class CliRunner { } isTestWorkersEnabled() { - if (this.testRunner.supportsTestWorkers === false) { + if (this.testRunner.supportsParallelTestSuiteRun === false) { return false; } - const testWorkers = this.test_settings.testWorkersEnabled && !singleSourceFile(this.argv); + const testWorkers = this.test_settings.testWorkersEnabled && !singleSourceFile(this.argv); if (!testWorkers) { if (this.argv.debug) { @@ -470,7 +470,7 @@ class CliRunner { if (isMobile(desiredCapabilities) && !this.usingServer(this.testEnvSettings[env])) { - if (Concurrency.isWorker()) { + if (Concurrency.isWorker()) { Logger.info('Disabling parallelism while running tests on mobile platform'); } diff --git a/lib/runner/test-runners/cucumber.js b/lib/runner/test-runners/cucumber.js index c464e55914..bb270a63f5 100644 --- a/lib/runner/test-runners/cucumber.js +++ b/lib/runner/test-runners/cucumber.js @@ -249,7 +249,7 @@ class CucumberRunnner extends Runner { return true; } - get supportsTestWorkers() { + get supportsParallelTestSuiteRun() { return false; } From e18e7495f46082a06bdfbceef61b77b40c867bea Mon Sep 17 00:00:00 2001 From: AutomatedTester Date: Fri, 15 Mar 2024 12:52:55 +0000 Subject: [PATCH 4/4] add a new test instead of updating a test --- .../testCucumberTestsInParallel.js | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/test/cucumber-integration-tests/testCucumberTestsInParallel.js b/test/cucumber-integration-tests/testCucumberTestsInParallel.js index a04c3cc419..f34c9702d7 100644 --- a/test/cucumber-integration-tests/testCucumberTestsInParallel.js +++ b/test/cucumber-integration-tests/testCucumberTestsInParallel.js @@ -5,17 +5,17 @@ const commandMocks = require('../lib/command-mocks.js'); const common = require('../common.js'); const MockServer = require('../lib/mockserver.js'); -describe('Cucumber integration - parallel running single formatter', function() { - beforeEach(function(done) { +describe('Cucumber integration - parallel running single formatter', function () { + beforeEach(function (done) { this.server = MockServer.init(null, {port: 10190}); this.server.on('listening', () => done()); }); - afterEach(function(done) { + afterEach(function (done) { Globals.afterEach.call(this, done); }); - it('testCucumberSampleTests in parallel with single formatter', function() { + it('testCucumberSampleTests in parallel with single formatter', function () { const source = [ path.join(__dirname, './sample_cucumber_tests/parallel/testSample.js') ]; @@ -41,7 +41,39 @@ describe('Cucumber integration - parallel running single formatter', function() }); }); - it('testCucumberSampleTests in parallel with multiple step definition files', function() { + it('testCucumberSampleTests in parallel with multiple step definition files', function () { + + commandMocks.elementText('5cc459b8-36a8-3042-8b4a-258883ea642b', 'xx'); + + const source = [ + path.join(__dirname, './sample_cucumber_tests/parallelWithMultipleDefinition') + ]; + + const {runTests} = common.require('index.js'); + + return runTests({ + source, + parallel: true, + verbose: true, + timeout: 10, + env: 'chrome', + silent: false, + tags: ['not @fail'], + format: 'progress', + config: path.join(__dirname, '../extra/cucumber-config-parallel.js'), + 'format-options': '', + ['retry-interval']: 5, + ['persist-globals']: true, + ['webdriver-host']: 'localhost', + ['start-process']: false, + ['webdriver-port']: 10190 + }, {}) + .then(errorOrFailed => { + assert.strictEqual(errorOrFailed, false); + }); + }); + + it('testCucumberSampleTests in parallel environments with multiple step definition files', function () { commandMocks.elementText('5cc459b8-36a8-3042-8b4a-258883ea642b', 'xx'); @@ -72,4 +104,4 @@ describe('Cucumber integration - parallel running single formatter', function() assert.strictEqual(errorOrFailed, false); }); }); -}); \ No newline at end of file +});