diff --git a/Gruntfile.js b/Gruntfile.js index 8b837fb..b0a536c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -96,6 +96,21 @@ module.exports = function(grunt) { } } }, + testArgsList: { + configFile:"test/testConf.js", + options: { + webdriverManagerUpdate: true, + args: { + grep: '#mytag' + } + } + }, + testWithoutArgsList: { + configFile:"test/testConf.js", + options: { + webdriverManagerUpdate: true + } + } }, // Unit tests. diff --git a/README.md b/README.md index b4c49f6..71adc64 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ Supported arguments are below. * beforeLaunch `string`: You can specify a file containing code to run once configs are read but before any environment setup. This will only run once, and before onPrepare. * onPrepare `string`: You can specify a file containing code to run once protractor is ready and available, and before the specs are executed. If multiple capabilities are being run, this will run once per capability. * webDriverProxy `string`: WebDriver proxy configuration to run remote tests +* grep `string`: Grep string used to match the specs to run. EX. `#tag` or `#tag|#tag2` #### options.output Type: `String` diff --git a/tasks/protractor_runner.js b/tasks/protractor_runner.js index c7ee1d1..f02b800 100644 --- a/tasks/protractor_runner.js +++ b/tasks/protractor_runner.js @@ -46,7 +46,7 @@ module.exports = function(grunt) { var keepAlive = opts['keepAlive']; var strArgs = ["seleniumAddress", "seleniumServerJar", "seleniumPort", "baseUrl", "rootElement", "browser", "chromeDriver", "chromeOnly", "directConnect", "sauceUser", "sauceKey", "sauceSeleniumAddress", "framework", "frameworkPath", "beforeLaunch", "onPrepare", "webDriverProxy"]; - var listArgs = ["specs", "exclude", "suite"]; + var listArgs = ["specs", "exclude", "suite", "grep"]; var boolArgs = ["includeStackTrace", "verbose"]; var objectArgs = ["params", "capabilities", "cucumberOpts", "mochaOpts"]; diff --git a/test/listArgs_test.js b/test/listArgs_test.js new file mode 100644 index 0000000..3c73ab7 --- /dev/null +++ b/test/listArgs_test.js @@ -0,0 +1,29 @@ +var exec = require('child_process').execSync; + +exports.testArgsList = function (test) { + var runnerStdOut = exec('grunt protractor:testArgsList --verbose'); + if (typeof runnerStdOut === 'object'){ + runnerStdOut = runnerStdOut.toString(); + } + if (runnerStdOut.indexOf('Spawn node with arguments:') > -1 && runnerStdOut.indexOf('--grep #mytag') > -1) { + test.ok(true, 'grep option test passed'); + test.done(); + } else { + test.ok(false, 'grep option not found'); + test.done(); + } +}; + +exports.testWithoutArgsList = function (test) { + var runnerStdOut = exec('grunt protractor:testWithoutArgsList --verbose'); + if (typeof runnerStdOut === 'object'){ + runnerStdOut = runnerStdOut.toString(); + } + if (runnerStdOut.indexOf('Spawn node with arguments:') > -1 && runnerStdOut.indexOf('--grep') === -1) { + test.ok(true, 'grep option is absent as expected'); + test.done(); + } else { + test.ok(false, 'grep option should be absent'); + test.done(); + } +};