diff --git a/.gitignore b/.gitignore index edbb589..0b9bb6c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ Gemfile.lock .DS_Store **/.DS_Store .byebug_history -.idea/ \ No newline at end of file +.idea/ +testrail-rspec-* \ No newline at end of file diff --git a/README.md b/README.md index 9253409..b67ed50 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ ### Features - [x] Update test results in the existing test run -- [x] Create dynamic test run and update test results in it +- [x] Create dynamic tlts in the existing test run +- [x] Update multi-testrail cases from a single automation scenario ## Installation @@ -30,8 +31,7 @@ require 'testrail-rspec' ## #Usage outline -#### Sync Case ID - +#### Update one case at a time Prefix TestRail Case ID on start of your rspec scenario; say, `C845` ```ruby @@ -52,6 +52,28 @@ Prefix TestRail Case ID on start of your rspec scenario; say, `C845` end ``` +#### Update multi-cases at a time + +Prefix multiple TestRail Case IDs on start of your rspec scenario; say, `C845 C845 your scenario description` + +```ruby + describe 'Verify Google Home Page' do + + scenario 'C847 C846 C845 verify the Google home page' do + expect(page).to have_content('Google') + end + + scenario 'C848 C849 verify the Google home page to fail' do + expect(page).to have_content('Goo gle') + end + + scenario 'verify the Google home page to fail' do + expect(page).to have_content('Goo gle') + end + + end +``` + #### TestRail details Provide TestRail details by creating a config file, `testrail_config.yml` in the project parent folder diff --git a/lib/testrail-rspec/update-testrails.rb b/lib/testrail-rspec/update-testrails.rb index e8a7aac..48c7e53 100644 --- a/lib/testrail-rspec/update-testrails.rb +++ b/lib/testrail-rspec/update-testrails.rb @@ -20,7 +20,15 @@ def initialize(scenario) def upload_result response = {} - case_id = @scenario.metadata[:description].split(' ').first.scan(/\d+/).first rescue nil + + case_list = [] + @scenario.metadata[:description].split(' ').map do |e| + val = e.scan(/\d+/).first + next if val.nil? + case_list << val + end + + return if case_list.empty? if (@scenario.exception) && (!@scenario.exception.message.include? 'pending') status_id = get_status_id 'failed'.to_sym @@ -40,13 +48,11 @@ def upload_result @run_id = @@run_id rescue @@run_id = nil unless @config['run_id'] @run_id = @@run_id = client.create_test_run("add_run/#{@config['project_id']}", { "suite_id": @config['suite_id']}) if @run_id.nil? - if case_id && @run_id + case_list.map do |case_id| response = client.send_post( "add_result_for_case/#{@run_id}/#{case_id}", { status_id: status_id, comment: message } ) - else - raise 'unable to get case id or run id' end response diff --git a/lib/testrail-rspec/version.rb b/lib/testrail-rspec/version.rb index 8dd0c32..fcbe114 100644 --- a/lib/testrail-rspec/version.rb +++ b/lib/testrail-rspec/version.rb @@ -1,3 +1,3 @@ module TestrailRspec - VERSION = '0.1.3'.freeze + VERSION = '0.1.4'.freeze end \ No newline at end of file diff --git a/spec/features/google_search_spec.rb b/spec/features/google_search_spec.rb index 560a00b..e0b29eb 100644 --- a/spec/features/google_search_spec.rb +++ b/spec/features/google_search_spec.rb @@ -17,4 +17,12 @@ skip "skipping this test" end + scenario 'C856 C859 C860 verify the Google home page to skip' do + expect(page).to have_content('Goo gle') + end + + scenario 'verify the Google home page to skip' do + expect(page).to have_content('Google') + end + end \ No newline at end of file