Class: TestRail::CucumberAdaptor

Inherits:
Adaptor
  • Object
show all
Defined in:
lib/testrail/cucumber_adaptor.rb

Instance Method Summary collapse

Methods inherited from Adaptor

#end_test_run, #initialize, #start_test_run

Constructor Details

This class inherits a constructor from TestRail::Adaptor

Instance Method Details

#resolve_from_scenario_outline(scenario) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/testrail/cucumber_adaptor.rb', line 39

def resolve_from_scenario_outline(scenario)
  {
    section_name: scenario.scenario_outline.feature.name.strip,
    test_name: scenario.scenario_outline.name.strip,
    success: !scenario.failed?,
    comment: scenario.exception
  }
end

#resolve_from_simple_scenario(scenario) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/testrail/cucumber_adaptor.rb', line 48

def resolve_from_simple_scenario(scenario)
  {
    section_name: scenario.feature.name.strip,
    test_name: scenario.name.strip,
    success: !scenario.failed?,
    comment: scenario.exception
  }
end

#submit(scenario) ⇒ Object

Submits an scenario test results If the test case exists, it will reuse the id, otherwise it will create a new Test Case in TestRails

Parameters:

  • scenario (Cucumber Scenario|Cucumber Scenario Outline)

    A test case scenario after execution



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/testrail/cucumber_adaptor.rb', line 23

def submit(scenario)
  return unless @enabled
  case scenario.class.name
  when 'Cucumber::RunningTestCase::ScenarioOutlineExample'
    test_results = resolve_from_scenario_outline(scenario)
  when 'Cucumber::Ast::ScenarioOutline'
    test_results = resolve_from_scenario_outline(scenario)
  when 'Cucumber::RunningTestCase::Scenario'
    test_results = resolve_from_simple_scenario(scenario)
  when 'Cucumber::Ast::Scenario'
    test_results = resolve_from_simple_scenario(scenario)
  end

  submit_test_result(test_results)
end