Class: QAT::Reporter::Formatter::ReqCoverage
- Inherits:
-
Object
- Object
- QAT::Reporter::Formatter::ReqCoverage
- Includes:
- Cucumber::Formatter::Duration, Cucumber::Formatter::Io, Formatter::Helper, Formatter::Loggable, Logger
- Defined in:
- lib/qat/reporter/formatter/req_coverage.rb
Overview
Namespace for ReqCoverage formatter
Instance Method Summary collapse
-
#initialize(config) ⇒ ReqCoverage
constructor
A new instance of ReqCoverage.
- #on_test_case_finished(event) ⇒ Object
- #on_test_case_started(event) ⇒ Object private
- #on_test_run_finished(event) ⇒ Object
- #tag_name(tag_name) ⇒ Object private
Constructor Details
#initialize(config) ⇒ ReqCoverage
Returns a new instance of ReqCoverage.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/qat/reporter/formatter/req_coverage.rb', line 28 def initialize(config) @config = config @io = ensure_io(config.out_stream, config.error_stream) ensure_outputter 'ReqCoverage' unless @config.dry_run? @ast_lookup = ::Cucumber::Formatter::AstLookup.new(config) @feature_hashes = [] config.on_event :test_case_started, &method(:on_test_case_started) config.on_event :test_case_finished, &method(:on_test_case_finished) config.on_event :test_run_finished, &method(:on_test_run_finished) @test_results = [] @feature_requirement_ids = [] @test_requirement_ids = [] @row_counter = 0 @flag_tag = nil end |
Instance Method Details
#on_test_case_finished(event) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/qat/reporter/formatter/req_coverage.rb', line 68 def on_test_case_finished event return if @config.dry_run? _test_case, result = *event.attributes @current_feature = nil test_status = if result.passed? if QAT::Reporter.const_defined?('Times') QAT::Reporter::Times.test_sla_status else "passed" end elsif result.failed? "failed" else "not_runned" end if @examples_values if @flag_tag == @test_id @row_counter += 1 else @row_counter = 1 end test_id = "#{@test_id}.#{@scenario[:id].split('').last}".to_f else @row_counter = 1 test_id = @test_id.to_i end duration = ::Cucumber::Formatter::DurationExtractor.new(result).result_duration human_duration = format_duration(duration) test_result = { test: test_id, requirement: @test_requirement_ids.uniq.compact, status: test_status, duration: duration, human_duration: human_duration } if test_result[:test] @test_results << test_result log.info({ 'message' => 'test execution', '_test' => test_result[:test], '_requirement' => test_result[:requirement], '_status' => test_result[:status], '_duration' => duration, '_human_duration' => human_duration }) end @test_requirement_ids = [] if @examples_values @flag_tag = @test_id if @flag_tag != @test_id end |
#on_test_case_started(event) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/qat/reporter/formatter/req_coverage.rb', line 53 def on_test_case_started(event) return if @config.dry_run? @row_number = nil @examples = nil test_case = event.test_case build(test_case, @ast_lookup) @test_id = nil @test_requirement_ids = [] @scenario[:tags].each do |tag| tag_name tag end end |
#on_test_run_finished(event) ⇒ Object
126 127 128 129 130 131 |
# File 'lib/qat/reporter/formatter/req_coverage.rb', line 126 def on_test_run_finished event return if @config.dry_run? publish_result @test_id = nil @test_requirement_ids = [] end |
#tag_name(tag_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 |
# File 'lib/qat/reporter/formatter/req_coverage.rb', line 46 def tag_name(tag_name) @test_id = tag_name.to_s.split('#')[1] if tag_name.match(/@test#(\d+)/) requirement_id = tag_name.to_s.split('#')[1] if tag_name.match(/@user_story#(\d+)/) @test_requirement_ids << requirement_id end |