Class: Gridium::TestRail
- Inherits:
-
Object
- Object
- Gridium::TestRail
- Defined in:
- lib/testrail.rb
Constant Summary collapse
- ENV_ERROR =
"Environment Variable not set!"- PASSED =
TestRail Statuses
1- BLOCKED =
2- UNTESTED =
3- RETEST =
4- FAILED =
5
Instance Method Summary collapse
- #add_case(rspec_test) ⇒ Object
- #add_run(name, desc) ⇒ Object
- #close_run ⇒ Object
-
#initialize ⇒ TestRail
constructor
A new instance of TestRail.
Constructor Details
#initialize ⇒ TestRail
Returns a new instance of TestRail.
17 18 19 20 21 22 23 24 |
# File 'lib/testrail.rb', line 17 def initialize if Gridium.config.testrail @url = ENV['GRIDIUM_TR_URL'].empty? || ENV['GRIDIUM_TR_URL'].nil? ? ENV_ERROR : ENV['GRIDIUM_TR_URL'] + '/index.php?/api/v2/' @user = ENV['GRIDIUM_TR_USER'].empty? || ENV['GRIDIUM_TR_USER'].nil? ? ENV_ERROR : ENV['GRIDIUM_TR_USER'] @password = ENV['GRIDIUM_TR_PW'].empty? || ENV['GRIDIUM_TR_PW'].nil? ? ENV_ERROR : ENV['GRIDIUM_TR_PW'] @pid = ENV['GRIDIUM_TR_PID'].empty? || ENV['GRIDIUM_TR_PID'].nil? ? ENV_ERROR : ENV['GRIDIUM_TR_PID'] end end |
Instance Method Details
#add_case(rspec_test) ⇒ Object
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.rb', line 49 def add_case(rspec_test) if Gridium.config.testrail Log.debug("[GRIDIUM::TestRail] Adding case: #{rspec_test} for RunID: #{@runid}") if rspec_test.nil? then raise(ArgumentError, "No test data was passed in.") end unless @runid.nil? r = _send_request('POST', "update_run/#{@runid}", {:case_ids => [rspec_test.[:testrail_id]]}) if rspec_test.exception status = FAILED = rspec_test.exception. else status = PASSED = '' end r = _send_request( 'POST', "add_result_for_case/#{@runid}/#{rspec_test.metadata[:testrail_id]}", status_id: status, comment: ) end end end |
#add_run(name, desc) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/testrail.rb', line 26 def add_run(name, desc) if Gridium.config.testrail Log.debug("[GRIDIUM::TestRail] Creating Test Run: name: #{name} desc: #{desc}") if name.nil? || name.empty? then raise(ArgumentError, "Empty Run Name - Run name is required") end r = _send_request('POST', "add_run/#{@pid}", {:name => name, :description => desc, :include_all => false}) Log.debug("Result: #{r}") unless r["id"].nil? @runid = r["id"] end end end |
#close_run ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/testrail.rb', line 40 def close_run if Gridium.config.testrail Log.debug("[GRIDIUM::TestRail] Closing RunID: #{@runid}") unless @runid.nil? r = _send_request('POST', "close_run/#{@runid}", nil) end end end |