Class: TestRail::Adaptor
- Inherits:
-
Object
- Object
- TestRail::Adaptor
- Defined in:
- lib/testrail/adaptor.rb
Instance Method Summary collapse
-
#end_test_run ⇒ Object
Checks to see if any of the tests in a particular test run have failed, if they have then the it will leave the run opened.
-
#initialize(enabled: false, test_suite: nil, url:, username:, password:, project_id:, suite_id:) ⇒ Adaptor
constructor
A new instance of Adaptor.
-
#start_test_run ⇒ Object
This method initiates a test run against a project, and specified testsuite.
-
#submit(example) ⇒ Object
Submits an example test results If the test case exists, it will reuse the id, otherwise it will create a new Test Case in TestRails.
Constructor Details
#initialize(enabled: false, test_suite: nil, url:, username:, password:, project_id:, suite_id:) ⇒ Adaptor
Returns a new instance of Adaptor.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/testrail/adaptor.rb', line 8 def initialize( enabled: false, test_suite: nil, url:, username:, password:, project_id:, suite_id: ) @enabled = enabled return unless @enabled if test_suite.nil? testrail_client = TestRail::APIClient.new(url) testrail_client.user = username testrail_client.password = password @test_suite = TestRail::TestRailClient.new(testrail_client).get_suite( project_id: project_id, suite_id: suite_id ) else @test_suite = test_suite end end |
Instance Method Details
#end_test_run ⇒ Object
Checks to see if any of the tests in a particular test run have failed, if they have then the it will leave the run opened. If there are no failed tests then it will call close the particular run.
86 87 88 89 90 |
# File 'lib/testrail/adaptor.rb', line 86 def end_test_run return if !@enabled || @test_run.nil? @test_run.submit_results @test_run.close unless @test_run.failure_count > 0 end |
#start_test_run ⇒ Object
This method initiates a test run against a project, and specified testsuite. ruby functional test file (.rb) containing a range of rspec test cases. Each rspec test case (in the ruby functional test file) will have a corresponding Test Case in TestRail. These Test Rail test cases will belong to a test suite that has the title of the corresponding ruby functional test file.
79 80 81 82 |
# File 'lib/testrail/adaptor.rb', line 79 def start_test_run return unless @enabled @test_run = @test_suite.start_test_run end |
#submit(example) ⇒ Object
Submits an example test results If the test case exists, it will reuse the id, otherwise it will create a new Test Case in TestRails
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/testrail/adaptor.rb', line 35 def submit(example) return unless @enabled case example.class.name when 'Cucumber::RunningTestCase::ScenarioOutlineExample' test_case_section = example.scenario_outline.feature.name test_case_section.strip! test_case_name = example.scenario_outline.name test_case_name.strip! test_result = !example.failed? test_comment = example.exception when 'Cucumber::RunningTestCase::Scenario' test_case_section = example.feature.name test_case_section.strip! test_case_name = example.name test_case_name.strip! test_result = !example.failed? test_comment = example.exception when 'RSpec::Core::Example' test_case_section = example.example_group.description test_case_section.strip! test_case_name = example.description test_case_name.strip! test_result = example.exception.nil? test_comment = example.exception end @test_run.add_test_result( section_name: test_case_section, test_name: test_case_name, success: test_result, comment: test_comment) end |