qat-cucumber 6.0.1 → 7.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9c88dd3b6d99831b87b91b80dbe1e677b5563e7a3e7e8d2abdb97791de509cc
4
- data.tar.gz: 3cb08d25fd39a460057fb86420e911ad33ae9d314df68c943ea5a6a09dd07741
3
+ metadata.gz: 52049a50f92285548892ab45b105aeda40630d3cb8051adfe644700b0e92189c
4
+ data.tar.gz: d0bc611a1eb4ddd61ee3510371421488776db8e6f0bccede00d123e55634d87a
5
5
  SHA512:
6
- metadata.gz: 8e7814752a7936af6cfa8754c670e025a06d7ae35a48a02fd20f6dcf111341d4dbb27d41b4f01062e36fa3d223a14af4ef9439c37743d375a639a4f306212364
7
- data.tar.gz: 2df7b3a8434602b19c9e73e8bba1c40123a44f7f2818c4063ea55744a05ba3b21a41f3fc774ec0dbd00d3776c3fe8e9be53f7e6174b1eb3cbece793fe5d19c92
6
+ metadata.gz: 1b1f39bceb8c052f341eb38cc55caaa9759516d89eb656eb1c7ed38b66f4a7da7c22a696b62b6b16267d88cb72b904c291cf5f89f8dea35de057049db42f4303
7
+ data.tar.gz: 21871419441011ffc39378b804d4b4d6281c709b5e8a4225eadac053ddf69b232a117fa12c1fa90efbad2e52788fbeef62a475a849df2777cd66d0a3b1c3a485
@@ -1,48 +1,48 @@
1
1
  require 'cucumber/formatter/html'
2
2
 
3
- #Extension to the cucumber module adding the embed video options
4
- module Cucumber
5
- #Extension to the formatter module adding the embed video options
6
- module Formatter
7
- #Extension to the html class adding the embed video options
8
- class Html
9
- #Method embed that also contains options to embed video case the extension is met
10
- def embed(src, mime_type, label)
11
- case (mime_type)
12
- when /^image\/(png|gif|jpg|jpeg)/
13
- unless File.file?(src) or src =~ /^data:image\/(png|gif|jpg|jpeg);base64,/
14
- type = mime_type =~ /;base[0-9]+$/ ? mime_type : mime_type + ";base64"
15
- src = "data:" + type + "," + src
16
- end
17
- embed_image(src, label)
18
- when /^text\/plain/
19
- embed_text(src, label)
20
- when /^video\/\w+/
21
- embed_video(src,mime_type, label)
22
- end
23
- end
24
-
25
- #Method to embed the video in the HTML Report
26
- def embed_video(src,mime_type, label)
27
- @video_id ||= 0
28
-
29
- if @io.respond_to?(:path) and File.file?(src)
30
- out_dir = Pathname.new(File.dirname(File.absolute_path(@io.path)))
31
- src = Pathname.new(File.absolute_path(src)).relative_path_from(out_dir)
32
- end
33
-
34
- @builder.span(:class => 'embed') do |pre|
35
- pre << %{
36
- <a href="" onclick="video=document.getElementById('video_div_#{@video_id}'); video.style.display = (video.style.display == 'none' ? 'block' : 'none');return false"><br>#{label}</a><br>&nbsp;
37
- <div id="video_div_#{@video_id}" style="display: none">
38
- <video id="video_#{@video_id}" autostart="0" width="800" height="600" controls> <source src="#{src}" type="#{mime_type}" ></video><br>
39
- <a href="#{src}" download="#{src}">Download Video</a>
40
- </div>}
41
- end
42
-
43
- @video_id += 1
44
- end
45
- end
46
- end
47
- end
3
+ # #Extension to the cucumber module adding the embed video options
4
+ # module Cucumber
5
+ # #Extension to the formatter module adding the embed video options
6
+ # module Formatter
7
+ # #Extension to the html class adding the embed video options
8
+ # class Html
9
+ # #Method embed that also contains options to embed video case the extension is met
10
+ # def embed(src, mime_type, label)
11
+ # case (mime_type)
12
+ # when /^image\/(png|gif|jpg|jpeg)/
13
+ # unless File.file?(src) or src =~ /^data:image\/(png|gif|jpg|jpeg);base64,/
14
+ # type = mime_type =~ /;base[0-9]+$/ ? mime_type : mime_type + ";base64"
15
+ # src = "data:" + type + "," + src
16
+ # end
17
+ # embed_image(src, label)
18
+ # when /^text\/plain/
19
+ # embed_text(src, label)
20
+ # when /^video\/\w+/
21
+ # embed_video(src,mime_type, label)
22
+ # end
23
+ # end
24
+ #
25
+ # #Method to embed the video in the HTML Report
26
+ # def embed_video(src,mime_type, label)
27
+ # @video_id ||= 0
28
+ #
29
+ # if @io.respond_to?(:path) and File.file?(src)
30
+ # out_dir = Pathname.new(File.dirname(File.absolute_path(@io.path)))
31
+ # src = Pathname.new(File.absolute_path(src)).relative_path_from(out_dir)
32
+ # end
33
+ #
34
+ # @builder.span(:class => 'embed') do |pre|
35
+ # pre << %{
36
+ # <a href="" onclick="video=document.getElementById('video_div_#{@video_id}'); video.style.display = (video.style.display == 'none' ? 'block' : 'none');return false"><br>#{label}</a><br>&nbsp;
37
+ # <div id="video_div_#{@video_id}" style="display: none">
38
+ # <video id="video_#{@video_id}" autostart="0" width="800" height="600" controls> <source src="#{src}" type="#{mime_type}" ></video><br>
39
+ # <a href="#{src}" download="#{src}">Download Video</a>
40
+ # </div>}
41
+ # end
42
+ #
43
+ # @video_id += 1
44
+ # end
45
+ # end
46
+ # end
47
+ # end
48
48
 
@@ -1,57 +1,57 @@
1
1
  require 'cucumber/formatter/junit'
2
2
 
3
- module Cucumber
4
- module Formatter
5
- # The formatter used for <tt>--format junit</tt>
6
- class Junit
3
+ # module Cucumber
4
+ # module Formatter
5
+ # # The formatter used for <tt>--format junit</tt>
6
+ # class Junit
7
7
 
8
- #Method to parse time in testsuite elements
9
- def end_feature(feature_data)
10
- @testsuite = Builder::XmlMarkup.new(:indent => 2)
11
- @testsuite.instruct!
12
- @testsuite.testsuite(
13
- :failures => feature_data[:failures],
14
- :errors => feature_data[:errors],
15
- :skipped => feature_data[:skipped],
16
- :tests => feature_data[:tests],
17
- :time => "%.3f" % feature_data[:time],
18
- :name => feature_data[:feature].name) do
19
- @testsuite << feature_data[:builder].target!
20
- end
21
-
22
- write_file(feature_result_filename(feature_data[:feature].file), @testsuite.target!)
23
- end
24
-
25
- #Method to parse time in testcase elements
26
- def build_testcase(result, scenario_designation, output)
27
- duration = ResultBuilder.new(result).test_case_duration
28
- @current_feature_data[:time] += duration
29
- classname = @current_feature_data[:feature].name
30
- name = scenario_designation
31
-
32
- @current_feature_data[:builder].testcase(:classname => classname, :name => name, :time => "%.3f" % duration) do
33
- if !result.passed? && result.ok?(@config.strict?)
34
- @current_feature_data[:builder].skipped
35
- @current_feature_data[:skipped] += 1
36
- elsif !result.passed?
37
- status = result.to_sym
38
- exception = get_backtrace_object(result)
39
- @current_feature_data[:builder].failure(:message => "#{status} #{name}", :type => status) do
40
- @current_feature_data[:builder].cdata! output
41
- @current_feature_data[:builder].cdata!(format_exception(exception)) if exception
42
- end
43
- @current_feature_data[:failures] += 1
44
- end
45
- @current_feature_data[:builder].tag!('system-out') do
46
- @current_feature_data[:builder].cdata! strip_control_chars(@interceptedout.buffer.join)
47
- end
48
- @current_feature_data[:builder].tag!('system-err') do
49
- @current_feature_data[:builder].cdata! strip_control_chars(@interceptederr.buffer.join)
50
- end
51
- end
52
- @current_feature_data[:tests] += 1
53
- end
54
- end
55
- end
56
- end
8
+ # #Method to parse time in testsuite elements
9
+ # def end_feature(feature_data)
10
+ # @testsuite = Builder::XmlMarkup.new(:indent => 2)
11
+ # @testsuite.instruct!
12
+ # @testsuite.testsuite(
13
+ # :failures => feature_data[:failures],
14
+ # :errors => feature_data[:errors],
15
+ # :skipped => feature_data[:skipped],
16
+ # :tests => feature_data[:tests],
17
+ # :time => "%.3f" % feature_data[:time],
18
+ # :name => feature_data[:feature].name) do
19
+ # @testsuite << feature_data[:builder].target!
20
+ # end
21
+ #
22
+ # write_file(feature_result_filename(feature_data[:feature].file), @testsuite.target!)
23
+ # end
24
+ #
25
+ # #Method to parse time in testcase elements
26
+ # def build_testcase(result, scenario_designation, output)
27
+ # duration = ResultBuilder.new(result).test_case_duration
28
+ # @current_feature_data[:time] += duration
29
+ # classname = @current_feature_data[:feature].name
30
+ # name = scenario_designation
31
+ #
32
+ # @current_feature_data[:builder].testcase(:classname => classname, :name => name, :time => "%.3f" % duration) do
33
+ # if !result.passed? && result.ok?(@config.strict)
34
+ # @current_feature_data[:builder].skipped
35
+ # @current_feature_data[:skipped] += 1
36
+ # elsif !result.passed?
37
+ # status = result.to_sym
38
+ # exception = get_backtrace_object(result)
39
+ # @current_feature_data[:builder].failure(:message => "#{status} #{name}", :type => status) do
40
+ # @current_feature_data[:builder].cdata! output
41
+ # @current_feature_data[:builder].cdata!(format_exception(exception)) if exception
42
+ # end
43
+ # @current_feature_data[:failures] += 1
44
+ # end
45
+ # @current_feature_data[:builder].tag!('system-out') do
46
+ # @current_feature_data[:builder].cdata! strip_control_chars(@interceptedout.buffer_string)
47
+ # end
48
+ # @current_feature_data[:builder].tag!('system-err') do
49
+ # @current_feature_data[:builder].cdata! strip_control_chars(@interceptederr.buffer_string)
50
+ # end
51
+ # end
52
+ # @current_feature_data[:tests] += 1
53
+ # end
54
+ # end
55
+ # end
56
+ # end
57
57
 
@@ -1,16 +1,16 @@
1
- require 'cucumber/core/test/result'
2
-
3
- #Patch for Cucumber::Core::Test::Result::Unknown to implement methods used by the formatters
4
- #@since 1.1.0
5
- class Cucumber::Core::Test::Result::Unknown
6
-
7
- #Dummy function
8
- def with_appended_backtrace(_)
9
- ''
10
- end
11
-
12
- #Dummy function
13
- def with_filtered_backtrace(_)
14
- ''
15
- end
16
- end
1
+ # require 'cucumber/core/test/result'
2
+ #
3
+ # #Patch for Cucumber::Core::Test::Result::Unknown to implement methods used by the formatters
4
+ # #@since 1.1.0
5
+ # class Cucumber::Core::Test::Result::Unknown
6
+ #
7
+ # #Dummy function
8
+ # def with_appended_backtrace(_)
9
+ # ''
10
+ # end
11
+ #
12
+ # #Dummy function
13
+ # def with_filtered_backtrace(_)
14
+ # ''
15
+ # end
16
+ # end
@@ -2,6 +2,7 @@
2
2
  require 'cucumber'
3
3
  require 'qat/logger'
4
4
 
5
+
5
6
  module QAT
6
7
  module Cucumber
7
8
  #Methods to execute with Cucumber Hooks and at_exit.
@@ -24,7 +25,7 @@ module QAT
24
25
 
25
26
  private
26
27
  def test_id(scenario)
27
- outline_id = get_outline_id(scenario)
28
+ # outline_id = get_outline_id(scenario)
28
29
 
29
30
  tags = scenario_tags(scenario)
30
31
  tag = tags.select { |tag| tag.match /^\@test\#/ }.first
@@ -35,39 +36,40 @@ module QAT
35
36
  'test_0'
36
37
  end
37
38
 
38
- "#{test_id}#{outline_id}"
39
- end
40
-
41
- def get_outline_id(scenario)
42
- if scenario.is_a? ::Cucumber::RunningTestCase::ScenarioOutlineExample
43
- test_case = scenario.instance_exec { @test_case }
44
- test_case_source = test_case.source
45
-
46
- tables = get_example_tables(test_case_source)
47
- table_lines = get_examples_size(tables)
48
- table_num = current_outline_index(tables, test_case_source)
49
- previous_outlines = count_previous_outlines(table_lines, table_num)
50
- "_#{previous_outlines + test_case_source[3].number}"
51
- else
52
- nil
53
- end
54
- end
55
-
56
- def get_example_tables(test_case_source)
57
- test_case_source[1].instance_exec { @examples_tables }
39
+ #"#{test_id}#{outline_id}"
40
+ "#{test_id}"
58
41
  end
59
42
 
60
- def get_examples_size(tables)
61
- tables.each.map { |table| table.example_rows.size }
62
- end
63
-
64
- def current_outline_index(tables, test_case_source)
65
- tables.index test_case_source[2]
66
- end
67
-
68
- def count_previous_outlines(table_lines, table_num)
69
- table_lines[0...table_num].inject(0) { |sum, lines| sum += lines; sum }
70
- end
43
+ # def get_outline_id(scenario)
44
+ # if scenario.is_a? ::Cucumber::RunningTestCase::ScenarioOutlineExample
45
+ # test_case = scenario.instance_exec { @test_case }
46
+ # test_case_source = test_case.source
47
+ #
48
+ # tables = get_example_tables(test_case_source)
49
+ # table_lines = get_examples_size(tables)
50
+ # table_num = current_outline_index(tables, test_case_source)
51
+ # previous_outlines = count_previous_outlines(table_lines, table_num)
52
+ # "_#{previous_outlines + test_case_source[3].number}"
53
+ # else
54
+ # nil
55
+ # end
56
+ # end
57
+ #
58
+ # def get_example_tables(test_case_source)
59
+ # test_case_source[1].instance_exec { @examples_tables }
60
+ # end
61
+ #
62
+ # def get_examples_size(tables)
63
+ # tables.each.map { |table| table.example_rows.size }
64
+ # end
65
+ #
66
+ # def current_outline_index(tables, test_case_source)
67
+ # tables.index test_case_source[2]
68
+ # end
69
+ #
70
+ # def count_previous_outlines(table_lines, table_num)
71
+ # table_lines[0...table_num].inject(0) { |sum, lines| sum += lines; sum }
72
+ # end
71
73
 
72
74
  extend self
73
75
  end
@@ -10,6 +10,6 @@ module QAT
10
10
  #@since 0.1.0
11
11
  module Cucumber
12
12
  # Represents QAT's version
13
- VERSION = '6.0.1'
13
+ VERSION = '7.0.4'
14
14
  end
15
15
  end
@@ -0,0 +1,86 @@
1
+ require_relative 'utility_function'
2
+
3
+ module QAT
4
+ module Formatter
5
+ # Helper for Formatters , most of the main methods are done to reduce code duplication
6
+ module Builder
7
+ include QAT::Formatter::UtilityFuction
8
+
9
+
10
+ def build (test_case, ast_lookup)
11
+ @background_hash = nil
12
+ uri = test_case.location.file
13
+ feature = ast_lookup.gherkin_document(uri).feature
14
+ feature(feature, uri)
15
+ background = feature.children.first.background
16
+ background(background) if background
17
+ scenario(ast_lookup.scenario_source(test_case), test_case)
18
+ end
19
+
20
+ def feature (feature, uri)
21
+ feature_tags = feature.tags
22
+ create_feature_hash feature, uri
23
+ return if feature_tags.empty?
24
+ tags_array = []
25
+ feature_tags.each { |tag| tags_array << tag.name }
26
+ @feature_hash[:tags] = tags_array
27
+ end
28
+
29
+ def scenario(scenario_source, test_case)
30
+ scenario = scenario_source.type == :Scenario ? scenario_source.scenario : scenario_source.scenario_outline
31
+ @scenario = {
32
+ id: "#{@feature_hash[:id]};#{create_id_from_scenario_source(scenario_source)}",
33
+ keyword: scenario.keyword,
34
+ name: test_case.name,
35
+ description: scenario.description || '',
36
+ line: get_lines_from_scenario(scenario_source, test_case),
37
+ type: 'scenario'
38
+ }
39
+
40
+ get_scenario_tags test_case.tags
41
+ end
42
+
43
+ def get_scenario_tags tags
44
+ if tags.empty?
45
+ @scenario[:tags] = []
46
+ else
47
+ tags_array = []
48
+
49
+ tags.each { |tag|
50
+ name = tag.name
51
+ if @test_id_tags
52
+ tags_array << name unless name.match(/@test#(\d+)/)
53
+ else
54
+ tags_array << name
55
+ end
56
+ }
57
+
58
+ @scenario[:tags] = tags_array
59
+ end
60
+ end
61
+
62
+
63
+ def create_id_from_scenario_source(scenario_source)
64
+ if scenario_source.type == :Scenario
65
+ @examples_values = nil
66
+ scenario_source.scenario.name
67
+ else
68
+ @examples_values = []
69
+ scenario_outline_name = scenario_source.scenario_outline.name
70
+ examples_name = scenario_source.examples.name
71
+ get_example_values scenario_source
72
+ @row_number = calculate_row_number(scenario_source)
73
+ "#{scenario_outline_name};#{examples_name};#{@row_number}"
74
+ end
75
+ end
76
+
77
+
78
+ def add_values_to_examples(cells)
79
+ @examples_values = cells.map do |data|
80
+ data[:value].to_s
81
+ end
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -1,8 +1,11 @@
1
1
  require 'fileutils'
2
2
  require 'cucumber/formatter/console'
3
3
  require 'cucumber/formatter/io'
4
+ require 'cucumber/formatter/ast_lookup'
4
5
  require 'cucumber/gherkin/formatter/escaping'
6
+ require 'cucumber/deprecate'
5
7
  require 'qat/logger'
8
+ require_relative 'helper'
6
9
  require_relative 'loggable'
7
10
 
8
11
  module QAT
@@ -15,88 +18,23 @@ module QAT
15
18
  include ::FileUtils
16
19
  include ::Cucumber::Formatter::Io
17
20
  include ::Cucumber::Gherkin::Formatter::Escaping
21
+ include ::Cucumber::Formatter
18
22
  include QAT::Formatter::Loggable
19
23
  include QAT::Logger
20
-
21
- #@api private
22
- def initialize(_, path_or_io, options)
23
- @options = options
24
-
25
- check_outputter path_or_io unless options[:dry_run]
26
- end
27
-
28
- #@api private
29
- def before_test_case test_case
30
- return if @options[:dry_run]
31
-
32
- unless @current_feature
33
- @current_feature = test_case.source[0]
34
- log.info { "Running #{@current_feature.keyword}: \"#{@current_feature.name}\"" }
35
- mdc_before_feature! @current_feature.name
36
- end
37
-
38
- @current_scenario = test_case.source[1]
39
- end
40
-
41
- #@api private
42
- def after_feature *_
43
- return if @options[:dry_run]
44
-
45
- log.info { "Finished #{@current_feature.keyword}: \"#{@current_feature.name}\"" }
46
- @current_feature = nil
47
- mdc_after_feature!
48
- end
49
-
50
- #@api private
51
- def after_test_case step, result
52
- return if @options[:dry_run]
53
-
54
- log.error { result.exception } if result.failed?
55
-
56
- log.info { "Finished #{@current_scenario.keyword}: \"#{format_scenario_name step}\" - #{result.to_sym}\n" } if @current_scenario
57
- end
58
-
59
- #@api private
60
- def before_test_step step
61
- return if @options[:dry_run]
62
-
63
- begin_test_step step do |type|
64
- case type
65
- when :after_step
66
- log.info "Step Done!" if @step_running
67
- when :before_scenario
68
- before_test_case step unless @current_feature
69
- log.info { "Running #{@current_scenario.keyword}: \"#{format_scenario_name step}\"" }
70
- when :before_step
71
- log.info "Step Done!\n" if @step_running
72
- step_name = "#{step.source.last.keyword}#{step.name}"
73
- log.info { "Step \"#{step_name}\"" }
74
- mdc_add_step! step_name
75
- end
76
- end
24
+ include QAT::Formatter::Helper
25
+
26
+ def initialize(config)
27
+ @config = config
28
+ @io = ensure_io(config.out_stream, config.error_stream)
29
+ @ast_lookup = ::Cucumber::Formatter::AstLookup.new(config)
30
+ @feature_hashes = []
31
+ config.on_event :test_case_started, &method(:on_test_case_started)
32
+ config.on_event :test_case_finished, &method(:on_test_case_finished)
33
+ config.on_event :test_step_started, &method(:on_test_step_started)
34
+ config.on_event :test_step_finished, &method(:on_test_step_finished)
35
+ config.on_event :test_run_finished, &method(:on_test_run_finished)
77
36
  end
78
37
 
79
- #@api private
80
- def puts obj
81
- return if @options[:dry_run]
82
-
83
- log.debug { obj }
84
- end
85
-
86
- private
87
- def format_scenario_name step
88
- return '' unless @current_scenario
89
- outline_number, outline_example = nil, nil
90
- scenario_name = if @current_scenario.is_a? ::Cucumber::Core::Ast::ScenarioOutline
91
- outline_example = step.source[3].values
92
- outline_number = calculate_outline_id(step)
93
- "#{@current_scenario.name} ##{outline_number}"
94
- else
95
- @current_scenario.name
96
- end
97
- mdc_before_scenario! @current_scenario.name, tags_from_test_step(step), outline_number, outline_example
98
- return scenario_name
99
- end
100
38
  end
101
39
  end
102
40
  end