Class: QAT::Formatter::Xray::TestIds

Inherits:
TestIds
  • Object
show all
Includes:
Cucumber::Formatter::Io, Helper
Defined in:
lib/qat/formatter/xray/test_ids.rb

Overview

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ TestIds

Returns a new instance of TestIds.

Since:

  • 1.0.0



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/qat/formatter/xray/test_ids.rb', line 13

def initialize(config)
  @config             = config
  @no_test_id         = {}
  @max_test_id        = 0
  @duplicate_test_ids = {}
  @test_id_mapping    = {}
  @io                 = ensure_io(config.out_stream, config.error_stream)
  @ast_lookup         = ::Cucumber::Formatter::AstLookup.new(@config)
  config.on_event :test_case_started, &method(:on_test_case_started)
  config.on_event :test_run_finished, &method(:on_test_run_finished)
end

Instance Method Details

#scenario_nameObject

Override because of tag condition

Since:

  • 1.0.0



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/qat/formatter/xray/test_ids.rb', line 27

def scenario_name
  path = "#{@current_feature[:uri]}:#{@scenario[:line]}"
  scenario_tags= @scenario[:tags]
  if scenario_tags.any? { |tag| tag.match(/@id:(\d+)/) }
      id           = scenario_tags.map { |tag| tag.match(/@id:(\d+)/) }.compact.first.captures.first.to_i
    @max_test_id = id if id > @max_test_id

    test_id_info = { name: @scenario[:name],
                     path:  path}

    if @test_id_mapping[id]
      if @duplicate_test_ids[id]
        @duplicate_test_ids[id].find do |dup|
          @exist = true if dup[:path]== test_id_info[:path]
        end
        @duplicate_test_ids[id] << test_id_info unless @exist
      else
        @duplicate_test_ids[id] = [@test_id_mapping[id], test_id_info] unless @test_id_mapping[id][:path] == test_id_info[:path]
      end
    else
      @test_id_mapping[id] = test_id_info
    end
  else
    @no_test_id[@scenario[:name]] = path unless scenario_tags.include?('@dummy_test')
  end
  @scenario[:tags] = []
end