Class: Maze::Plugins::BugsnagReportingPlugin

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/plugins/bugsnag_reporting_plugin.rb

Instance Method Summary collapse

Instance Method Details

#test_case(test_case) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/maze/plugins/bugsnag_reporting_plugin.rb', line 17

def test_case(test_case)
  configuration.on_event(:test_step_finished) do |event|
    @last_test_step = event.test_step if event.result.failed?
  end

  configuration.on_event(:test_case_finished) do |event|

    # Ensure we're in the correct test case and that it's failed
    next unless event.test_case.eql?(test_case) && event.result.failed?

    Bugsnag.notify(event.result.exception) do |bsg_event|
      unless @last_test_step.nil?
        bsg_event.context = @last_test_step.location
        bsg_event.grouping_hash = test_case.name + @last_test_step.location
        bsg_event.(:'scenario', {
          'failing step': @last_test_step.to_s,
          'failing step location': @last_test_step.location
        })
      end
      bsg_event.(:'scenario', {
        'scenario name': test_case.name,
        'scenario location': test_case.location,
        'scenario tags': test_case.tags,
        'scenario duration (mS)': event.result.duration.nanoseconds/1000000
      })
    end
  end

  super
end