Module: Qtest

Defined in:
lib/connectQtest.rb

Class Method Summary collapse

Class Method Details

.QtestPostTestResult(name, runid, failMessage) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/connectQtest.rb', line 13

def Qtest.QtestPostTestResult (name,runid,failMessage) 

  startdate = DateTime.now 
  enddate = DateTime.now 

  puts "Uploading ..... Testcase"
  puts name
  $id = runid
  puts $id

  response = RestClient::Request.execute(
    method: :post, 
    url: "#$qtesturl/api/v3/projects/#$projectid/test-runs/#$id/auto-test-logs",
    payload:{                 
        "name" => name,   
        "automation_content" => "sample-demo-api-AutomationTestLog",   
        "status" => failMessage  ? "PASS" : "FAIL",
        "exe_start_date" => startdate,    
        "exe_end_date" => enddate,  
        "note" => failMessage ? "Testcase is passed" : "Testcase is failed"
      }.to_json,

        headers:{
          "Content-Type"=> "application/json",
          "Cache-Control" => "no-cache",
          "verify_ssl" => "OpenSSL::SSL::VERIFY_NONE",
          "Authorization" => "#$authkey"
      }
  )

  puts "response code :"
  puts response.code
  puts response.body

  if response.code == 201
      puts $status = "PASS"
      puts "Testcase is passed"
  else
      puts $status = "FAIL"
      puts "Testcase is failed"
  end
  puts "status of the charter is...: " + $status
	 
end