cukerail 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cukerail/version.rb +1 -1
- data/lib/cukerail.rb +15 -9
- data/spec/cukerail_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66343a93c60cfe15d03e38401b48d5ebf7cf2016
|
4
|
+
data.tar.gz: c4d4777b290d374c4fd5821cbecee6d01feed315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 651441f7d9354a6b292525f9e2f906cf380786738664b7ba4e13de8594d51b2df0dc199f13a0df1193091a5ec82d456ebd7ce2233e9185f38dc8c2bbede9ccfa
|
7
|
+
data.tar.gz: 53dd0678946cda73413fd90d77b7a11b012427c13c3a41cf2a2d8d9a3db5352c2f38a96d23a817de27f86d99844e512f77941e8ef7b88fd99984c118cb285f87
|
data/lib/cukerail/version.rb
CHANGED
data/lib/cukerail.rb
CHANGED
@@ -2,9 +2,9 @@ require "cukerail/version"
|
|
2
2
|
require "cukerail/testrail"
|
3
3
|
module Cukerail
|
4
4
|
class Sender
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :testrail_api_client,:failed_step
|
6
6
|
def initialize(runtime, io, options)
|
7
|
-
@
|
7
|
+
@testrail_api_client = TestRail::APIClient.new(ENV['TESTRAIL_BASE_URL'],ENV['TESTRAIL_USER'],ENV['TESTRAIL_PASSWORD'])
|
8
8
|
end
|
9
9
|
|
10
10
|
def after_test_case(test_case,result)
|
@@ -16,7 +16,9 @@ module Cukerail
|
|
16
16
|
@id = get_id(test_case)
|
17
17
|
raise 'No id found' unless @id
|
18
18
|
send_steps(test_case,@id)
|
19
|
-
|
19
|
+
if ENV['TESTRUN']
|
20
|
+
send_result(test_case,result,@id,ENV['TESTRUN'])
|
21
|
+
end
|
20
22
|
end
|
21
23
|
|
22
24
|
def tag_name(tag_name)
|
@@ -31,8 +33,8 @@ module Cukerail
|
|
31
33
|
def after_test_step(step,result)
|
32
34
|
unless result.passed?
|
33
35
|
# only the first non-passed step
|
34
|
-
|
35
|
-
|
36
|
+
failed_step[:step] ||= step
|
37
|
+
failed_step[:result] ||= result
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -49,7 +51,7 @@ module Cukerail
|
|
49
51
|
project_id = /\d+/.match(tags.select{|tag| tag.name =~/project/}.first.name)[0]
|
50
52
|
suite_id = /\d+/.match(tags.select{|tag| tag.name =~/suite/}.first.name)[0]
|
51
53
|
title = extract_title(test_case)
|
52
|
-
found_case =
|
54
|
+
found_case = testrail_api_client.send_get("get_cases/#{project_id}&suite_id=#{suite_id}").select{|c| c['title'] == title}.first
|
53
55
|
if found_case
|
54
56
|
result= found_case['id']
|
55
57
|
else
|
@@ -91,14 +93,14 @@ module Cukerail
|
|
91
93
|
end.join("\n")
|
92
94
|
is_manual = test_case.tags.any?{|tag| tag.name =~/manual/}
|
93
95
|
data = {'title'=>extract_title(test_case),'type_id'=>(is_manual ? 7 : 1 ),'custom_steps'=>steps_as_string}
|
94
|
-
|
96
|
+
testrail_api_client.send_post("update_case/#{id}",data)
|
95
97
|
end
|
96
98
|
|
97
99
|
def create_new_case(project_id,suite_id,sub_section_id,test_case)
|
98
100
|
is_manual = test_case.tags.any?{|tag| tag.name =~/manual/}
|
99
101
|
steps_as_string = test_case.test_steps.map{|step| step.source.last}.select{|step| step.is_a?(Cucumber::Core::Ast::Step)}.map{|step| "#{step.keyword}#{step.name}"}.join("\n")
|
100
102
|
data = {'title'=>extract_title(test_case),'type_id'=>(is_manual ? 7 : 1 ),'custom_steps'=>steps_as_string}
|
101
|
-
|
103
|
+
testrail_api_client.send_post("add_case/#{sub_section_id || suite_id}", data)
|
102
104
|
end
|
103
105
|
|
104
106
|
def send_result(test_case,result,id,testrun)
|
@@ -123,7 +125,11 @@ module Cukerail
|
|
123
125
|
end
|
124
126
|
defects = test_case.tags.select{|tag| tag.name =~/jira_/}.map{|ticket| /STORE-\d+/.match(ticket.name)[0]}.join(" ")
|
125
127
|
report_on_result = {status_id:testrail_status[:id],comment:failure_message,defects:defects}
|
126
|
-
|
128
|
+
begin
|
129
|
+
testrail_api_client.send_post("add_result_for_case/#{testrun}/#{id}",report_on_result)
|
130
|
+
rescue => e
|
131
|
+
puts "#{e.message} testrun=#{testrun} test case id=#{id}"
|
132
|
+
end
|
127
133
|
end
|
128
134
|
|
129
135
|
def extract_title(test_case)
|
data/spec/cukerail_spec.rb
CHANGED
@@ -3,4 +3,15 @@ require 'spec_helper'
|
|
3
3
|
describe Cukerail do
|
4
4
|
let(:sender){Testrail::Cukerail.new}
|
5
5
|
|
6
|
+
context 'no failed step' do
|
7
|
+
before(:each) do
|
8
|
+
sender.testrail_api_client = instance_double(TestRail::APIClient)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "sends 'test failed before any steps ran' to TestRail" do
|
12
|
+
# allow(sender).to receive(:failed_step).and_return({
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
6
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cukerail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Small
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|