qat-cucumber 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +674 -0
  3. data/bin/qat +5 -0
  4. data/lib/qat/cli/generator/project.rb +32 -0
  5. data/lib/qat/cli/generator.rb +48 -0
  6. data/lib/qat/cli/main.rb +102 -0
  7. data/lib/qat/cli/plugins/core.rb +19 -0
  8. data/lib/qat/cli.rb +52 -0
  9. data/lib/qat/cucumber/core_ext/formatter/html.rb +48 -0
  10. data/lib/qat/cucumber/core_ext/formatter/junit.rb +57 -0
  11. data/lib/qat/cucumber/core_ext/result.rb +16 -0
  12. data/lib/qat/cucumber/core_ext.rb +3 -0
  13. data/lib/qat/cucumber/hooks/scenario.rb +76 -0
  14. data/lib/qat/cucumber/hooks.rb +72 -0
  15. data/lib/qat/cucumber/logger.rb +49 -0
  16. data/lib/qat/cucumber/time.rb +55 -0
  17. data/lib/qat/cucumber/version.rb +15 -0
  18. data/lib/qat/cucumber/world.rb +40 -0
  19. data/lib/qat/cucumber.rb +76 -0
  20. data/lib/qat/formatter/console.rb +101 -0
  21. data/lib/qat/formatter/dashboard.rb +84 -0
  22. data/lib/qat/formatter/loggable/mdc.rb +74 -0
  23. data/lib/qat/formatter/loggable/scenario_info.rb +40 -0
  24. data/lib/qat/formatter/loggable.rb +92 -0
  25. data/lib/qat/formatter/scenario/name.rb +47 -0
  26. data/lib/qat/formatter/tags.rb +81 -0
  27. data/lib/qat/formatter/test_ids.rb +93 -0
  28. data/lib/qat/jenkins.rb +43 -0
  29. data/lib/qat/project/Gemfile +13 -0
  30. data/lib/qat/project/Rakefile +3 -0
  31. data/lib/qat/project/config/cucumber.yml +13 -0
  32. data/lib/qat/project/config/default.yml +1 -0
  33. data/lib/qat/project/config/env-dummy/hosts.yml +9 -0
  34. data/lib/qat/project/config/env-dummy/jenkins.yml +7 -0
  35. data/lib/qat/project/config/env-dummy/logger.yml +23 -0
  36. data/lib/qat/project/config/env-dummy/time.yml +11 -0
  37. data/lib/qat/project/features/feature.feature +45 -0
  38. data/lib/qat/project/features/step_definitions/steps.rb +4 -0
  39. data/lib/qat/project/features/support/env.rb +6 -0
  40. data/lib/qat/project/features/support/hooks.rb +32 -0
  41. data/lib/qat/tasks/list.rb +50 -0
  42. data/lib/qat/tasks/steps.rb +20 -0
  43. data/lib/qat/tasks/tags/test_ids/helpers.rb +105 -0
  44. data/lib/qat/tasks/tags/test_ids/report.rb +41 -0
  45. data/lib/qat/tasks/tags/test_ids.rb +60 -0
  46. data/lib/qat/tasks/tags.rb +2 -0
  47. data/lib/qat/tasks/test.rb +35 -0
  48. data/lib/qat/tasks.rb +8 -0
  49. metadata +193 -0
@@ -0,0 +1,93 @@
1
+ require 'cucumber/formatter/io'
2
+ require 'json'
3
+
4
+ module QAT
5
+ module Formatter
6
+ class TestIds
7
+ include Cucumber::Formatter::Io
8
+
9
+ def initialize(runtime, path_or_io, options)
10
+ @io = ensure_io(path_or_io)
11
+ @tags = []
12
+ @scenario_tags = []
13
+ @no_test_id = {}
14
+ @max_test_id = 0
15
+ @duplicate_test_ids = {}
16
+ @test_id_mapping = {}
17
+ @options = options
18
+ end
19
+
20
+ def before_feature(feature)
21
+ @in_scenarios = false
22
+ end
23
+
24
+ def tag_name(tag_name)
25
+ @scenario_tags << tag_name if @in_scenarios
26
+ end
27
+
28
+ def after_tags(tags)
29
+ @in_scenarios = true unless @in_scenarios
30
+ end
31
+
32
+ def scenario_name(keyword, name, file_colon_line, source_indent)
33
+ if @scenario_tags.any? { |tag| tag.match(/@test#(\d+)/) }
34
+ id = @scenario_tags.map { |tag| tag.match(/@test#(\d+)/) }.compact.first.captures.first.to_i
35
+ @max_test_id = id if id > @max_test_id
36
+
37
+ test_id_info = { name: name,
38
+ path: file_colon_line }
39
+
40
+ if @test_id_mapping[id]
41
+ if @duplicate_test_ids[id]
42
+ @duplicate_test_ids[id] << test_id_info
43
+ else
44
+ @duplicate_test_ids[id] = [@test_id_mapping[id], test_id_info]
45
+ end
46
+ else
47
+ @test_id_mapping[id] = test_id_info
48
+ end
49
+
50
+ else
51
+ @no_test_id[name] = file_colon_line unless @scenario_tags.include?('@dummy_test')
52
+ end
53
+ @scenario_tags = []
54
+ end
55
+
56
+ def after_features(features)
57
+ publish_result
58
+ @io.flush
59
+ end
60
+
61
+ private
62
+ def publish_result
63
+ content = {
64
+ max: @max_test_id,
65
+ untagged: @no_test_id,
66
+ mapping: Hash[@test_id_mapping.sort],
67
+ duplicate: Hash[@duplicate_test_ids.sort]
68
+ }
69
+
70
+ if @duplicate_test_ids.any?
71
+ dups_info = @duplicate_test_ids.map do |id, dups|
72
+ text = dups.map { |dup| "Scenario: #{dup[:name]} - #{dup[:path]}" }.join("\n")
73
+ "TEST ID #{id}:\n#{text}\n"
74
+ end
75
+
76
+ duplicates_info = <<-TXT.gsub(/^\s*/, '')
77
+ ------------------------------------
78
+ Duplicate test ids found!
79
+ ------------------------------------
80
+ #{dups_info.join("\n")}
81
+ TXT
82
+ puts duplicates_info
83
+ end
84
+
85
+ @io.puts(content.to_json({
86
+ indent: ' ',
87
+ space: ' ',
88
+ object_nl: "\n"
89
+ }))
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,43 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ require 'qat/logger'
4
+ require_relative 'cucumber/version'
5
+
6
+ module QAT
7
+
8
+ #Jenkins helper. Should be required by the Cucumber module then running tests in a Jenkins server.
9
+ #@since 0.1.0
10
+ module Jenkins
11
+
12
+ #Default Jenkins environment variables to add register in the +QAT::Logger+.
13
+ DEFAULT_ENV_VARS = [
14
+ 'BUILD_NUMBER',
15
+ 'BUILD_URL',
16
+ 'NODE_NAME',
17
+ 'JOB_NAME',
18
+ 'SVN_REVISION',
19
+ 'GIT_COMMIT'
20
+ ]
21
+
22
+
23
+ #Register Jenkins environment variables in the Log4r::MDC hash.
24
+ #By default only the {DEFAULT_ENV_VARS} will be registered.
25
+ #@param [Hash] opts Options to modify default registry
26
+ #@option opts [Array<String>] :ignore ([]) List of default environment variables to ignore.
27
+ #@option opts [Array<String>] :add ([]) List of non default environment variables to add.
28
+ #@since 0.1.0
29
+ #@see http://log4r.rubyforge.org/rdoc/log4r/rdoc/MDC.html Log4r MDC
30
+ def self.register_vars(opts={})
31
+ ignore_list = opts[:ignore] || []
32
+ add_list = opts[:add] || []
33
+
34
+ list = DEFAULT_ENV_VARS + add_list - ignore_list
35
+
36
+ list.each do |var|
37
+ Log4r::MDC.put var, ENV[var] if ENV[var]
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # QAT is a Cucumber-based toolkit for automating tests. (https://gitlab.readinessit.com:8083/qa-toolkit/qat-core)
4
+ gem 'qat', '~> 2.0', '>= 2.0.0'
5
+
6
+ # QAT-Web is a browser controller for Web testing (http://gitlab.readinessit.com:8083/qa-toolkit/qat-web)
7
+ #gem 'qat-web', '~> 2.0', '>= 2.0.0'
8
+
9
+ # Ruby headless display interface (http://leonid.shevtsov.me/en/headless)
10
+ #gem 'headless', '~> 2.3', '>= 2.3.1'
11
+
12
+ # The next generation developer focused tool for automated testing of webapps (https://github.com/seleniumhq/selenium)
13
+ #gem 'selenium-webdriver', '~> 2.53', '>= 2.53.4'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env rake
2
+ # -*- encoding : utf-8 -*-
3
+ require 'qat/tasks'
@@ -0,0 +1,13 @@
1
+ qat: &qat >
2
+ --format QAT::Formatter::Console
3
+ --format html --out public/index.html
4
+ --format junit --out public/
5
+ --strict
6
+
7
+ standard: &standard >
8
+ --format html --out public/index.html
9
+ --format junit --out features/reports
10
+
11
+ flat: &flat --format pretty
12
+
13
+ default: *qat
@@ -0,0 +1 @@
1
+ env: 'env-dummy'
@@ -0,0 +1,9 @@
1
+ frontend:
2
+ host: 'frontend.app.domain'
3
+ username: 'admin'
4
+ password: 'admin'
5
+
6
+ backend:
7
+ host: '192.168.x.x'
8
+ username: 'app'
9
+ password: 'app'
@@ -0,0 +1,7 @@
1
+ #Uncomment the next lines to manipulate environment variables reported from jenkins
2
+ #env_vars:
3
+ # add:
4
+ # - EXECUTOR_NUMBER
5
+ # - JENKINS_URL
6
+ # ignore:
7
+ # - SVN_REVISION
@@ -0,0 +1,23 @@
1
+ log4r_config:
2
+ loggers:
3
+ - name: QAT
4
+ level: INFO
5
+ outputters:
6
+ - QAT
7
+
8
+ outputters:
9
+ - name: QAT
10
+ type: QatConsoleOutputter
11
+ default: true
12
+ formatter:
13
+ type: QatFormatter
14
+ colors: true
15
+
16
+ - type: QatRemoteOutputter
17
+ name: ReqCoverage
18
+ gelf_server: "127.0.0.1"
19
+ gelf_port: 12202
20
+ facility: 'QAT Requirement Coverage'
21
+ formatter:
22
+ type: PatternFormatter
23
+ pattern: "%m"
@@ -0,0 +1,11 @@
1
+ sync:
2
+ host: 'sync.host.com'
3
+ kill_if_failed: false
4
+ method: 'ntp' #or 'ssh' or user defined method
5
+ #opts: #option for sync methods
6
+ # username: ''
7
+ # password: ''
8
+ # port: 22 #default for SSH
9
+ # command: 'date' #SSH only
10
+
11
+ #zone: "Auckland" #As defined in http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html
@@ -0,0 +1,45 @@
1
+ @epic#1 @feature#2 @user_story#3 @dummy_feature
2
+ Feature: some feature
3
+ In order to do something
4
+ As someone
5
+ I want to specify scenarios
6
+
7
+ Background: Some option precondition
8
+ Given true
9
+
10
+ @test#4 @dummy_test
11
+ Scenario: true
12
+ When true
13
+ Then true
14
+
15
+ @test#5 @dummy_test
16
+ Scenario Outline: Many trues
17
+ When <true>
18
+ Then <true>
19
+ Examples:
20
+ | true |
21
+ | true |
22
+ | true |
23
+ | true |
24
+ | true |
25
+
26
+ @test#6 @dummy_test
27
+ Scenario: Some other trueness
28
+ When true
29
+ Then true
30
+
31
+ @test#7 @dummy_test
32
+ Scenario Outline: Regretion outline
33
+ When <true>
34
+ Then <true>
35
+ Examples:
36
+ | true |
37
+ | true |
38
+ | true |
39
+ | true |
40
+ | true |
41
+
42
+ @test#8 @dummy_test
43
+ Scenario: normal regretion
44
+ When true
45
+ Then true
@@ -0,0 +1,4 @@
1
+ Given /^true$/ do
2
+ assert true
3
+ end
4
+
@@ -0,0 +1,6 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'qat/cucumber'
3
+
4
+ ############################################
5
+ # Requires for your code libraries go here #
6
+ ############################################
@@ -0,0 +1,32 @@
1
+ #-*- encoding : utf-8 -*-
2
+
3
+ #Uncomment all necessary custom hooks
4
+
5
+ # AfterConfiguration do
6
+ # # Your code here
7
+ # end
8
+
9
+ # Before do |scenario|
10
+ # # Your code here
11
+ # end
12
+
13
+ # Around do |scenario, block|
14
+ # # Your code here
15
+ #
16
+ # #DON'T FORGET TO CALL THE SCENARIO'S BLOCK!!!!
17
+ # block.call
18
+
19
+ # # Your code here
20
+ # end
21
+
22
+ # After do |scenario|
23
+ # # Your code here
24
+ # end
25
+
26
+ # AfterStep do |step|
27
+ # # Your code here
28
+ # end
29
+
30
+ # at_exit do
31
+ # # Your code here
32
+ # end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env rake
2
+ #encoding: utf-8
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+ require 'rake/testtask'
6
+ require_relative '../formatter/scenario/name'
7
+ require_relative '../formatter/tags'
8
+
9
+ namespace :qat do
10
+ namespace :list do
11
+ desc 'Lists scenarios by tag'
12
+ task :by_tag, :tag do |_, params|
13
+ tag = params[:tag]
14
+ raise ArgumentError.new "A tag is needed to execute the task!" unless tag
15
+ raise ArgumentError.new "Tag '#{tag}' is invalid!" unless tag.start_with?('@')
16
+ ENV['CUCUMBER_OPTS'] = nil
17
+ Cucumber::Rake::Task.new('by_tag', 'Lists scenarios by tag') do |task|
18
+ task.cucumber_opts = ['--no-profile',
19
+ '--dry-run',
20
+ '--format', 'QAT::Formatter::Scenario::Name',
21
+ '--tags', tag]
22
+ task.fork = false
23
+ end.runner.run
24
+ end
25
+
26
+ desc 'List all scenarios without tags'
27
+ task :untagged do
28
+ ENV['CUCUMBER_OPTS'] = nil
29
+ Cucumber::Rake::Task.new('untagged', 'List all scenarios without tags') do |task|
30
+ task.cucumber_opts = ['--no-profile',
31
+ '--dry-run',
32
+ '--format', 'QAT::Formatter::Tags']
33
+ task.fork = false
34
+ end.runner.run
35
+ end
36
+
37
+ desc 'List all duplicated names for scenarios'
38
+ task :dup_names, [:path] do |_, args|
39
+ ENV['CUCUMBER_OPTS'] = nil
40
+ Cucumber::Rake::Task.new('dup_names', 'List all duplicated names for scenarios') do |task|
41
+ task.cucumber_opts = [args[:path],
42
+ '--no-profile',
43
+ '--dry-run',
44
+ '--format', 'QAT::Formatter::Scenario::Name',
45
+ '--out', 'scenarios.json'].compact
46
+ task.fork = false
47
+ end.runner.run
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env rake
2
+ #encoding: utf-8
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+ require 'rake/testtask'
6
+
7
+ namespace :qat do
8
+ namespace :steps do
9
+ desc 'Automatic validation step definitions for test scenarios'
10
+ task :validation do
11
+ ENV['CUCUMBER_OPTS'] = nil
12
+ Cucumber::Rake::Task.new('validation', 'Automatic validation step definitions for test scenarios') do |task|
13
+ task.bundler = false
14
+ task.cucumber_opts = ['--no-profile',
15
+ '--dry-run',
16
+ '--format progress']
17
+ end.runner.run
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,105 @@
1
+ # namespace for test ids utility methods and objects
2
+ module TestIds
3
+ # helper methods for test id manipulation
4
+ module Helpers
5
+ # Tags all untagged scenarios present in the test id report
6
+ #@param report [TestIds::Report] test id report
7
+ def tag_untagged(report)
8
+ max_test_id = report.max_id
9
+ untagged = report.untagged
10
+
11
+ if untagged.any?
12
+ files = map_untagged(untagged)
13
+
14
+ announce_changes(files)
15
+
16
+ update_test_ids(files, max_test_id)
17
+ else
18
+ puts "There are no scenarios without test id. Last test id given was '@test##{max_test_id}'."
19
+ end
20
+ end
21
+
22
+ private
23
+ # Returns all files containing untagged scenarios and their respective scenario line
24
+ #@param untagged [Array] list of untagged scenarios
25
+ #@return [Array]
26
+ def map_untagged(untagged)
27
+ files = {}
28
+
29
+ untagged.values.each do |file_colon|
30
+ file, colon = file_colon.split(':')
31
+ files[file] ||= []
32
+ files[file] << colon.to_i
33
+ end
34
+
35
+ files
36
+ end
37
+
38
+ # Announces to STDOUT the files that will be changed (test ids added)
39
+ #@param files [Array] list of files to change
40
+ #@see TestIds::Helpers#map_untaged
41
+ def announce_changes(files)
42
+ puts "Giving test ids to scenarios:"
43
+ puts files.to_json({
44
+ indent: ' ',
45
+ space: ' ',
46
+ object_nl: "\n"
47
+ })
48
+ end
49
+
50
+ # Rewrites the untagged files adding the missing test ids
51
+ #@param files [Array] list of files to change
52
+ #@param max_test_id [Integer] current max test id
53
+ def update_test_ids(files, max_test_id)
54
+ #iterate in file to give test id
55
+ begin
56
+ file_lines = []
57
+ files.each { |file, lines| max_test_id = rewrite_file(file, lines, max_test_id) }
58
+ rescue
59
+ path = File.join(Dir.pwd, 'public', 'test_ids_failed.feature')
60
+ puts "Tag attribution failed! Check '#{path}' for more information!"
61
+ File.write(path, file_lines.join)
62
+ end
63
+ end
64
+
65
+ # Rewrites the target file in the identified lines.
66
+ # Returns the max test id after the file update.
67
+ #@param file [String] file to rewrite
68
+ #@param lines [Array] lines to edit (add test id)
69
+ #@param max_test_id [Integer] current max test id
70
+ #@return [Integer]
71
+ def rewrite_file(file, lines, max_test_id)
72
+ norm_lines = lines.map { |line| line - 1 }
73
+ file_path = File.join(Dir.pwd, file)
74
+ file_lines = File.readlines(file_path)
75
+
76
+ norm_lines.size.times do
77
+ line = norm_lines.shift
78
+ puts "Editing file #{file} @ line #{line}."
79
+ max_test_id = add_tags(file_lines, line, max_test_id)
80
+ end
81
+
82
+ File.write(file_path, file_lines.join)
83
+
84
+ max_test_id
85
+ end
86
+
87
+ # Adds the test id tag to the identified line to edit
88
+ # Returns the max test id after the file update.
89
+ #@param file_lines [Array] Set of file lines
90
+ #@param line [Integer] index of line to edit
91
+ #@param max_test_id [Integer] current max test id
92
+ #@return [Integer]
93
+ def add_tags(file_lines, line, max_test_id)
94
+ if file_lines[line-1].match(/^\s*@\w+/)
95
+ file_lines[line-1] = " #{file_lines[line-1].strip} @test##{max_test_id += 1}\n"
96
+ else
97
+ file_lines[line] = " @test##{max_test_id += 1}\n#{file_lines[line]}"
98
+ end
99
+
100
+ max_test_id
101
+ end
102
+
103
+ extend self
104
+ end
105
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'helpers'
2
+
3
+ # namespace for test ids utility methods and objects
4
+ module TestIds
5
+ # the test id report wrapper
6
+ class Report
7
+ include Helpers
8
+
9
+ attr_reader :path, :content
10
+
11
+ def initialize(path)
12
+ @path = path
13
+ @content = JSON.parse(File.read(path))
14
+ end
15
+
16
+ # Returns the report max test id
17
+ def max_id
18
+ @max_id ||= @content['max']
19
+ end
20
+
21
+ # Returns the report untagged tests information
22
+ def untagged
23
+ @untagged ||= @content['untagged']
24
+ end
25
+
26
+ # Returns the report test id mapping to scenarios information
27
+ def mapping
28
+ @mapping ||= @content['mapping']
29
+ end
30
+
31
+ # Returns the report duplicate test id information
32
+ def duplicate
33
+ @duplicate ||= @content['duplicate']
34
+ end
35
+
36
+ # Tags all untagged scenario with a test id
37
+ def tag_untagged!
38
+ tag_untagged(self)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env rake
2
+ #encoding: utf-8
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+ require 'rake/testtask'
6
+ require 'json'
7
+ require 'fileutils'
8
+ require 'awesome_print'
9
+ require_relative '../../formatter/test_ids'
10
+ require_relative 'test_ids/report'
11
+ require_relative 'test_ids/helpers'
12
+
13
+ namespace :qat do
14
+ namespace :tags do
15
+ def run_report_task!
16
+ begin
17
+ Rake::Task['qat:tags:report_test_ids'].invoke
18
+ rescue SystemExit => exception
19
+ exitstatus = exception.status
20
+ @kernel.exit(exitstatus) unless exitstatus == 0
21
+ end
22
+ end
23
+
24
+ desc 'Generates the test id report in JSON'
25
+ task :report_test_ids do
26
+ FileUtils.mkdir('public') unless File.exists?(File.join(Dir.pwd, 'public'))
27
+ ENV['CUCUMBER_OPTS'] = nil
28
+ Cucumber::Rake::Task.new('test_ids', 'Generates test ids as tags for tests without test id') do |task|
29
+ task.bundler = false
30
+ task.fork = false
31
+ task.cucumber_opts = ['--no-profile',
32
+ '--dry-run',
33
+ '--format', 'QAT::Formatter::TestIds',
34
+ '--out', 'public/test_ids.json']
35
+ end.runner.run
36
+ end
37
+
38
+ desc 'Validates the existing test ids and checks for duplicates'
39
+ task :validate_test_ids do
40
+ run_report_task!
41
+ #read json file
42
+ file_path = File.realpath(File.join(Dir.pwd, 'public', 'test_ids.json'))
43
+ report = TestIds::Report.new(file_path)
44
+
45
+ exitstatus = report.duplicate.any? ? 1 : 0
46
+
47
+ exit(exitstatus)
48
+ end
49
+
50
+ desc 'Generates test ids as tags for tests without test id'
51
+ task :test_ids do
52
+ run_report_task!
53
+ #read json file
54
+ file_path = File.realpath(File.join(Dir.pwd, 'public', 'test_ids.json'))
55
+ report = TestIds::Report.new(file_path)
56
+
57
+ report.tag_untagged!
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,2 @@
1
+ #encoding: utf-8
2
+ require_relative 'tags/test_ids'
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env rake
2
+ #encoding: utf-8
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+ require 'rake/testtask'
6
+
7
+ namespace :qat do
8
+ namespace :test do
9
+ def clear_reports_folder!
10
+ mkdir_p 'public'
11
+ rm_rf ::File.join('public', '*')
12
+ end
13
+
14
+ Cucumber::Rake::Task.new('run', 'Run all test scenarios')
15
+
16
+ desc 'Run a complete feature'
17
+ task :feature, :feature_name do |_, params|
18
+ feature_name = params[:feature_name]
19
+ raise ArgumentError.new "A feature is needed to execute the task!" unless feature_name
20
+ Cucumber::Rake::Task.new(:feature) do
21
+ ENV['FEATURE'] = Dir.glob(File.join('features', '**', "#{feature_name}.feature")).first
22
+ end.runner.run
23
+ end
24
+
25
+ desc 'Run all test scenarios containing given tags'
26
+ task :tags, :tags do |_, params|
27
+ tags = params[:tags].is_a?(String) ? [params[:tags]] : params[:tags].to_a
28
+ raise ArgumentError.new "A tag is needed to execute the task!" unless tags.any?
29
+ ENV['CUCUMBER_OPTS'] = "#{ENV['CUCUMBER_OPTS']} --tags #{tags.join(',')}"
30
+ Cucumber::Rake::Task.new('run', 'Run all test scenarios containing given tags') do |task|
31
+ task.bundler = false
32
+ end.runner.run
33
+ end
34
+ end
35
+ end
data/lib/qat/tasks.rb ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ #encoding: utf-8
3
+ #@version 1.0
4
+ require_relative 'cucumber/core_ext/result'
5
+ require_relative 'tasks/list'
6
+ require_relative 'tasks/steps'
7
+ require_relative 'tasks/tags'
8
+ require_relative 'tasks/test'