diff --git a/Gruntfile.js b/Gruntfile.js index dafb8fc..bda9322 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,10 +9,36 @@ module.exports = function (grunt) { } }, cucumberjs: { - files: 'features', - options: { - steps: 'features/step_definitions', - format: 'pretty' + test1: { + files: 'features', + options: { + steps: 'features/step_definitions', + format: 'pretty' + } + }, + test2: { + files: 'features/tags.feature', + options: { + steps: 'features/step_definitions', + format: 'pretty', + tags: '@tag' + } + }, + test3: { + files: 'features/tags.feature', + options: { + steps: 'features/step_definitions', + format: 'pretty', + tags: ['@wip', '~@tag'] + } + }, + test4: { + files: 'features/tags.feature', + options: { + steps: 'features/step_definitions', + format: 'pretty', + tags: ['@wip', '@tag'] + } } } }); @@ -21,5 +47,7 @@ module.exports = function (grunt) { grunt.loadTasks('tasks'); - grunt.registerTask('default', ['jshint', 'cucumberjs']); + grunt.registerTask('default', ['jshint', 'cucumberjs:test1']); + + grunt.registerTask('tag-tests', ['cucumberjs:test2', 'cucumberjs:test3', 'cucumberjs:test4']) }; diff --git a/README.md b/README.md index a1ec8b9..4c505ba 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ when this option is specified, and all loading becomes explicit. Files under directories named "support" are always loaded first. #### tags -Type: `String` +Type: `String` or `Array` Default: `''` @@ -58,6 +58,11 @@ this represents boolean NOT. Example: by a comma, which represents logical OR. Example: `tags: '@dev,@wip'` +To represent a logical AND, use an array. +This is useful if you want to skip certain features +and run other specific features. Example: +`tags: ['~@wip', '@dev']` + #### format Type: `String` diff --git a/features/tags.feature b/features/tags.feature new file mode 100644 index 0000000..3da5fee --- /dev/null +++ b/features/tags.feature @@ -0,0 +1,27 @@ +Feature: Testing tags + As a grunt-cucumber-js dev + I want a Testing.feature file with tags + So that I can test the tag functionality of cucumber-js-task + + @wip + Scenario: Tagged wip + Given I have the number 1 and 3 + When I add them together + Then I should have 4 + + @tag + Scenario: Tagged tag + Given I have the number 1 and 3 + When I add them together + Then I should have 4 + + Scenario: No tags + Given I have the number 1 and 3 + When I add them together + Then I should have 4 + + @wip @tag + Scenario: Tagged wip and tag + Given I have the number 1 and 3 + When I add them together + Then I should have 4 diff --git a/tasks/cucumber-js-task.js b/tasks/cucumber-js-task.js index 45e37a7..d36e4c9 100644 --- a/tasks/cucumber-js-task.js +++ b/tasks/cucumber-js-task.js @@ -53,8 +53,13 @@ module.exports = function (grunt) { } if (! _.isEmpty(tags)) { - execOptions.push('-t'); - execOptions.push(tags); + if (typeof tags === "string") { + tags = [tags]; + } + for (var i=0; i < tags.length; i++) { + execOptions.push('-t'); + execOptions.push(tags[i]); + } } if (! _.isEmpty(format)) {