Class: WatirTestlinkFramework::TestLinkPlan
- Inherits:
-
Object
- Object
- WatirTestlinkFramework::TestLinkPlan
- Defined in:
- lib/watir_testlink_framework.rb
Class Method Summary collapse
- .execute_cases(tl, envstr, spectask, test_cases, dryrun) ⇒ Object
- .make_env_string(envarr) ⇒ Object
- .planid_by_name(tl, name) ⇒ Object
- .report_cases(tl, plan_id, cases, envstring) ⇒ Object
-
.run_plan_cases(plans_string, spectask = 'spec', dryrun = false) ⇒ Object
plans_string comma seperated string with plans.
- .testlinkplanconnection ⇒ Object
Class Method Details
.execute_cases(tl, envstr, spectask, test_cases, dryrun) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/watir_testlink_framework.rb', line 67 def self.execute_cases(tl, envstr,spectask, test_cases,dryrun) test_cases.each do |tc| tc_customfield = tl.test_case_custom_field_design_value(tl.project_id($config['testlink']['project']), tc[1][0]['full_external_id'], tc[1][0]['version'].to_i, 'RSPEC CASE ID',{:details=>''}) exec_string = "#{envstr}bundle exec rake testlink:#{spectask} SPEC_OPTS=\"-e #{tc_customfield}\"" if dryrun puts exec_string else system exec_string end end end |
.make_env_string(envarr) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/watir_testlink_framework.rb', line 84 def self.make_env_string(envarr) envstr='' envarr.each do | varname,varvalue| envstr+= "#{varname.upcase}='#{varvalue}' " end return envstr end |
.planid_by_name(tl, name) ⇒ Object
28 29 30 31 |
# File 'lib/watir_testlink_framework.rb', line 28 def self.planid_by_name(tl,name) plan_id = tl.test_plan_by_name($config['testlink']['project'], name) return plan_id[0][:id] end |
.report_cases(tl, plan_id, cases, envstring) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/watir_testlink_framework.rb', line 92 def self.report_cases(tl, plan_id, cases, envstring) cases_arr ={} require 'pp' Dir["reports/*.xml"].each do | report | case_arr = XmlSimple::xml_in(report) cases_arr[case_arr['testcase'][0]['name']] = case_arr end cases.each do | tc | tc_customfield = tl.test_case_custom_field_design_value(tl.project_id($config['testlink']['project']), tc[1][0]['full_external_id'], tc[1][0]['version'].to_i, 'RSPEC CASE ID',{:details=>''}) if cases_arr.has_key?(tc_customfield) = {} notes='' if cases_arr[tc_customfield]['failures'] == '0' status ='p' elsif cases_arr[tc_customfield]['failures'] == '1' notes += "Message: " + cases_arr[tc_customfield]['testcase'][0]['failure'][0]['message'] notes += "\n" notes += "Type: " + cases_arr[tc_customfield]['testcase'][0]['failure'][0]['type'] notes += "\n" notes += "Content: " + cases_arr[tc_customfield]['testcase'][0]['failure'][0]['content'] notes += "\n" notes += "EnvString: " + envstring status ='f' else status = 'b' end ['notes'] = notes tl.report_test_case_result(plan_id, tc[0], status, ) end end end |
.run_plan_cases(plans_string, spectask = 'spec', dryrun = false) ⇒ Object
plans_string comma seperated string with plans
34 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 |
# File 'lib/watir_testlink_framework.rb', line 34 def self.run_plan_cases(plans_string, spectask='spec', dryrun=false) tl = self.testlinkplanconnection plans = plans_string.split(';') plans.each do | plan | plan_id = self.planid_by_name(tl, plan.strip) test_cases = tl.test_cases_for_test_plan(plan_id) #create new build buildname = "watirbuild_#{Time.new}" tl.create_build(plan_id, buildname, 'created by watir_testlink_framework') if $config['testlink'].has_key?("multi_env") && $config['testlink']['multi_env'] != 0 $config['testlink']['testplans'][plan.strip].each do | envname, envarr | envstr = make_env_string(envarr) self.execute_cases(tl, envstr, spectask, test_cases, dryrun) self.report_cases(tl, plan_id, test_cases, envstr) if spectask=='junit' && !dryrun end else envstr = make_env_string($config['testlink']['testplans'][plan.strip]) self.execute_cases(tl, envstr, spectask, test_cases, dryrun) self.report_cases(tl, plan_id, test_cases, envstr) if spectask=='junit' && !dryrun end end end |
.testlinkplanconnection ⇒ Object
22 23 24 25 26 |
# File 'lib/watir_testlink_framework.rb', line 22 def self.testlinkplanconnection server = $config['testlink']['xmlrpc_url'] dev_key = $config['testlink']['apikey'] return TestLinker.new(server, dev_key) end |