From f9f2f206d89a7963f7c290b619f4f8572f15485f Mon Sep 17 00:00:00 2001 From: prashanth-sams Date: Wed, 25 Mar 2020 09:53:55 +0400 Subject: [PATCH] disable testrail and skip specific tesrun id deletion --- README.md | 26 ++++++++++++++++++++++++++ lib/testrail-rspec/update-testrails.rb | 4 +++- lib/testrail-rspec/version.rb | 2 +- testrail_config.yml | 6 ++++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5db7beb..e8339b5 100755 --- a/README.md +++ b/README.md @@ -7,8 +7,10 @@ - [x] Create dynamic test run and update test results in it - [x] Update multi-testrail cases from a single automation scenario - [x] Delete/clean all the existing test runs in a project's suite before test run +- [x] Skip specific test-runs from deletion, when `clean_testrun` is set `true` - [x] Static status comments on all the scenarios - [x] Support for RSpec `shared examples` +- [x] Disable `testrail-rspec` execution on-demand ## Installation @@ -150,6 +152,30 @@ end ``` Set, `clean_testrun: false` if you don't want to clean the existing test runs; but this keyword is optional. +6. To skip specific test-runs from deletion, when `clean_testrun` is set `true` + ```yaml + testrail: + url: https://your_url.testrail.io/ + user: your@email.com + password: ****** + clean_testrun: true + skip_testrun_ids: 473, 475 + project_id: 10 + suite_id: 110 + ``` + Here, `skip_testrun_ids: value` is optional. + +7. To disable `testrail-rspec` execution + ```yaml + testrail: + url: https://your_url.testrail.io/ + user: your@email.com + password: ****** + run_id: 111 + allow: no + ``` + Here, `skip_testrun_ids: value` is optional. + #### Hooks Update the results through `Hooks` on end of each test diff --git a/lib/testrail-rspec/update-testrails.rb b/lib/testrail-rspec/update-testrails.rb index ff0a256..5a764c3 100644 --- a/lib/testrail-rspec/update-testrails.rb +++ b/lib/testrail-rspec/update-testrails.rb @@ -14,12 +14,13 @@ def initialize(scenario) raise 'TestRail configuration file is required' end + return if [@config['allow'].nil?, @config['allow']].all? false setup_testrail_client config_validator if $config_validator.nil? end def upload_result - + return if [@config['allow'].nil?, @config['allow']].all? false response = {} case_list = [] @@ -105,6 +106,7 @@ def get_status_id(status) def cleaner test_run_list = client.send_get("get_runs/#{@config['project_id']}") test_run_list.map do |list| + next if !@config['skip_testrun_ids'].nil? && @config['skip_testrun_ids'].to_s.delete(' ').split(',').any?(list['id'].to_s) client.send_post("delete_run/#{list['id']}", {"suite_id": @config['suite_id']}) end end diff --git a/lib/testrail-rspec/version.rb b/lib/testrail-rspec/version.rb index 3ccaf43..1816ad1 100644 --- a/lib/testrail-rspec/version.rb +++ b/lib/testrail-rspec/version.rb @@ -1,3 +1,3 @@ module TestrailRspec - VERSION = '0.1.7'.freeze + VERSION = '0.1.8'.freeze end \ No newline at end of file diff --git a/testrail_config.yml b/testrail_config.yml index 4c0b8ff..118dac0 100644 --- a/testrail_config.yml +++ b/testrail_config.yml @@ -3,6 +3,8 @@ testrail: user: your_username password: your_password run_id: - clean_testrun: false + clean_testrun: true + skip_testrun_ids: , project_id: - suite_id: \ No newline at end of file + suite_id: + allow: yes \ No newline at end of file