Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed run-multiple #482

Merged
merged 8 commits into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/command/run-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const copyOptions = ['steps', 'reporter', 'verbose', 'config', 'reporter-options
// codeceptjs run:multiple all - will launch all suites
// codeceptjs run:multiple smoke regression'

let suiteId = 1;

module.exports = function (suites, options) {
// registering options globally to use in config
process.profile = options.profile;
Expand Down Expand Up @@ -71,7 +73,8 @@ function runSuite(suite, suiteConf, browser) {
return;
}

let overriddenConfig = config;
// clone config
let overriddenConfig = Object.assign({}, config);

if (suiteBrowsers.indexOf(browser) === -1) {
throw new Error(`Browser ${browser} not found in multiple suite "${suite}" config`);
Expand All @@ -85,13 +88,15 @@ function runSuite(suite, suiteConf, browser) {
overriddenConfig.helpers = replaceValue(overriddenConfig.helpers, key, browserConfig[key]);
}

let outputDir = suite + JSON.stringify(browserConfig).replace(/[^\d\w]+/g, '_') + suiteId;

// tweaking default output directories and for mochawesome
overriddenConfig = replaceValue(overriddenConfig, 'output', `${config.output}/${suite}_${browser}/`);
overriddenConfig = replaceValue(overriddenConfig, 'reportDir', `${config.output}/${suite}_${browser}/`);
overriddenConfig = replaceValue(overriddenConfig, 'output', path.join(config.output, outputDir));
overriddenConfig = replaceValue(overriddenConfig, 'reportDir', path.join(config.output, outputDir));

// override grep param and collect all params
let params = ['run',
'--child', `${suite}:${browser}`,
'--child', `${suiteId++}.${suite}:${browser}`,
'--override', JSON.stringify(overriddenConfig)
];

Expand Down
21 changes: 15 additions & 6 deletions lib/command/run.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
'use strict';
let getConfig = require('./utils').getConfig;
let getTestRoot = require('./utils').getTestRoot;
let deepMerge = require('./utils').deepMerge;
let Codecept = require('../codecept');
let Config = require('../config');
const getConfig = require('./utils').getConfig;
const getTestRoot = require('./utils').getTestRoot;
const deepMerge = require('./utils').deepMerge;
const fileExists = require('../utils').fileExists;
const path = require('path');
const fs = require('fs');
const Config = require('../config');
const Codecept = require('../codecept');
const output = require('../output');

module.exports = function (test, options) {
// registering options globally to use in config
process.profile = options.profile;
let configFile = options.config;
let codecept;
let codecept, outputDir;

let testRoot = getTestRoot(configFile);
let config = getConfig(configFile);
if (options.override) {
config = Config.append(JSON.parse(options.override));
}

if (!fileExists(outputDir = path.join(testRoot, config.output))) {
output.print('creating output directory: ' + outputDir);
fs.mkdirSync(outputDir);
}

try {
codecept = new Codecept(config, options);
codecept.init(testRoot, function (err) {
Expand Down
1 change: 0 additions & 1 deletion test/runner/codecept_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ describe('CodeceptJS Runner', () => {
});

it('should run dynamic config', (done) => {
console.log(codecept_run_config('config.js'));
exec(codecept_run_config('config.js'), (err, stdout, stderr) => {
stdout.should.include('Filesystem'); // feature
assert(!err);
Expand Down
38 changes: 18 additions & 20 deletions test/runner/run_multiple_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('CodeceptJS Multiple Runner', function() {
it('should execute one suite with browser', (done) => {
exec(codecept_run+'default:firefox', (err, stdout, stderr) => {
stdout.should.include('CodeceptJS'); // feature
stdout.should.include('[default:firefox] print browser ');
stdout.should.not.include('[default:chrome] print browser ');
stdout.should.include('.default:firefox] print browser ');
stdout.should.not.include('.default:chrome] print browser ');
assert(!err);
done();
});
Expand All @@ -29,8 +29,8 @@ describe('CodeceptJS Multiple Runner', function() {
it('should execute one suite with browser', (done) => {
exec(codecept_run+'default:firefox', (err, stdout, stderr) => {
stdout.should.include('CodeceptJS'); // feature
stdout.should.include('[default:firefox] print browser ');
stdout.should.not.include('[default:chrome] print browser ');
stdout.should.include('.default:firefox] print browser ');
stdout.should.not.include('.default:chrome] print browser ');
assert(!err);
done();
});
Expand All @@ -39,22 +39,22 @@ describe('CodeceptJS Multiple Runner', function() {
it('should execute all suites', (done) => {
exec(codecept_run+'--all', (err, stdout, stderr) => {
stdout.should.include('CodeceptJS'); // feature
stdout.should.include('[default:firefox] print browser ');
stdout.should.include('[default:chrome] print browser ');
stdout.should.include('[mobile:safari] print browser ');
stdout.should.include('[mobile:android] print browser ');
stdout.should.include('[1.default:chrome] print browser ');
stdout.should.include('[2.default:firefox] print browser ');
stdout.should.include('[3.mobile:android] print browser ');
stdout.should.include('[4.mobile:safari] print browser ');
assert(!err);
done();
});
});

it('should execute mutiple suites', (done) => {
exec(codecept_run+'default mobile', (err, stdout, stderr) => {
it('should execute multiple suites', (done) => {
exec(codecept_run+'mobile default ', (err, stdout, stderr) => {
stdout.should.include('CodeceptJS'); // feature
stdout.should.include('[default:firefox] print browser ');
stdout.should.include('[default:chrome] print browser ');
stdout.should.include('[mobile:safari] print browser ');
stdout.should.include('[mobile:android] print browser ');
stdout.should.include('[1.mobile:android] print browser ');
stdout.should.include('[2.mobile:safari] print browser ');
stdout.should.include('[3.default:chrome] print browser ');
stdout.should.include('[4.default:firefox] print browser ');
assert(!err);
done();
});
Expand All @@ -63,15 +63,13 @@ describe('CodeceptJS Multiple Runner', function() {
it('should print steps', (done) => {
exec(codecept_run+'default --steps', (err, stdout, stderr) => {
stdout.should.include('CodeceptJS'); // feature
stdout.should.include('[default:firefox] print browser ');
stdout.should.include('[default:firefox] • I print browser');
stdout.should.include('[default:chrome] print browser ');
stdout.should.include('[default:chrome] • I print browser');
stdout.should.include('[2.default:firefox] print browser ');
stdout.should.include('[2.default:firefox] • I print browser');
stdout.should.include('[1.default:chrome] print browser ');
stdout.should.include('[1.default:chrome] • I print browser');
assert(!err);
done();
});
});



});