testrailtagging 0.3.8.3 → 0.3.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/files/testrail_rspec_integration.rb +44 -8
- data/lib/files/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af7c34382755322b02544cb166a43b304a37e6b5
|
4
|
+
data.tar.gz: 3ff0363f332f5144430cd08cf9c9eba4be717c07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64a8c220b778ab6e8f6c634a7bb893576d6fe4211c36207d5338a75f2b6094edb8885f937788a0bebae20bc32c61f828421458de60d6e3d6f95951538462d340
|
7
|
+
data.tar.gz: f124e7cb3756f6779f50d2845302675a71c836ff9e2d3e0ee178481355218cd0a860380d79b75824a7c459c3545e7fe252a2e62f4f8e072152f54cf759b1711d
|
data/README.md
CHANGED
@@ -46,6 +46,14 @@ Then you set an environment variable called TESTRAIL_RUN_ID, with that value. Fo
|
|
46
46
|
|
47
47
|
`export TESTRAIL_RUN_ID=14153`
|
48
48
|
|
49
|
+
You can also set an optional environment variable to report results in batches, rather than after each test
|
50
|
+
case.
|
51
|
+
This helps reduce traffic to Testrail and also provides less flakiness in results not being posted when
|
52
|
+
something slow down testrail. To do this, add the following variable and set it to whatever number of test
|
53
|
+
case results you'd like to have posted at a time:
|
54
|
+
|
55
|
+
`TESTRAIL_BATCH_SIZE=15`
|
56
|
+
|
49
57
|
Next, in your RSpec configuration file (usually spec_helper.rb) you need to call a registration function:
|
50
58
|
|
51
59
|
|
@@ -22,6 +22,8 @@ module TestRailRSpecIntegration
|
|
22
22
|
class TestRailPlanFormatter
|
23
23
|
RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed, :start, :stop
|
24
24
|
public
|
25
|
+
@@cases = []
|
26
|
+
|
25
27
|
def initialize(out)
|
26
28
|
@out = out
|
27
29
|
end
|
@@ -30,6 +32,10 @@ module TestRailRSpecIntegration
|
|
30
32
|
@@product = product
|
31
33
|
end
|
32
34
|
|
35
|
+
def set_test_run_id(run_id)
|
36
|
+
@@run_id = run_id
|
37
|
+
end
|
38
|
+
|
33
39
|
def test_id_key
|
34
40
|
case @@product
|
35
41
|
when :bridge
|
@@ -66,6 +72,14 @@ module TestRailRSpecIntegration
|
|
66
72
|
end
|
67
73
|
end
|
68
74
|
|
75
|
+
# Initialize the batch size for test rail batching based on environment variable.
|
76
|
+
# One test is the default, in case people don't want to batch or haven't provided the variable.
|
77
|
+
if !ENV["TESTRAIL_BATCH_SIZE"].nil?
|
78
|
+
@batch_size = ENV["TESTRAIL_BATCH_SIZE"]
|
79
|
+
else
|
80
|
+
@batch_size = 1
|
81
|
+
end
|
82
|
+
|
69
83
|
# Pull down ALL the test cases from testrail. Granted this is more than what rspec will actually
|
70
84
|
# execute. But there is no safe way to append a test case to a test run in a parallel environment.
|
71
85
|
# The Testrail API is just too limited.
|
@@ -76,9 +90,14 @@ module TestRailRSpecIntegration
|
|
76
90
|
puts "Count of tests to be run: #{TestRailRSpecIntegration.get_run_count}"
|
77
91
|
puts "Count of tests that entered filter: #{TestRailRSpecIntegration.get_total_count}"
|
78
92
|
|
93
|
+
puts "Batching test results in groups of #{@batch_size}"
|
79
94
|
@test_case_hash = TestRailOperations.get_test_run_cases(@testrail_run_id)
|
80
95
|
# save the test case ID's that were actually executed
|
81
96
|
@executed_test_ids = []
|
97
|
+
|
98
|
+
# Need a class variable for after suite hooks to post results,
|
99
|
+
# since the after suite hooks are defined outside the class
|
100
|
+
set_test_run_id(@testrail_run_id)
|
82
101
|
end
|
83
102
|
|
84
103
|
# This gets called after all tests are run
|
@@ -108,8 +127,8 @@ module TestRailRSpecIntegration
|
|
108
127
|
return unless active
|
109
128
|
example = notification.example
|
110
129
|
result = example.execution_result
|
111
|
-
|
112
130
|
testrail_ids = example.metadata[test_id_key]
|
131
|
+
|
113
132
|
return unless testrail_ids.present?
|
114
133
|
completion_message = ""
|
115
134
|
|
@@ -120,21 +139,28 @@ module TestRailRSpecIntegration
|
|
120
139
|
completion_message.gsub!(/\[(\d)+m/, '')
|
121
140
|
end
|
122
141
|
|
123
|
-
cases = [] # the test cases
|
124
142
|
Array(testrail_ids).each do |id|
|
125
143
|
tc = @test_case_hash[id.to_i]
|
126
144
|
next unless tc # A test case ID exists in the rspec file, but not on testrail
|
127
145
|
tc.set_status(result.status, completion_message)
|
128
|
-
cases << tc
|
146
|
+
@@cases << tc
|
129
147
|
@executed_test_ids << id.to_i
|
130
148
|
end
|
131
149
|
|
132
|
-
|
150
|
+
# Batches together test cases before posting. Relies on environment variable TESTRAIL_BATCH_SIZE to determine
|
151
|
+
# batch size.
|
152
|
+
# Relies on an 'after suite' hook to capture and post results for any number of remaining test cases less
|
153
|
+
# than the batch size
|
154
|
+
if @@cases.size >= @batch_size.to_i
|
155
|
+
TestRailPlanFormatter.post_results @@cases
|
156
|
+
@@cases.clear
|
157
|
+
end
|
133
158
|
end
|
134
159
|
|
135
160
|
# test_cases is an array of TestCase instances
|
136
|
-
def post_results(test_cases)
|
161
|
+
def self.post_results(test_cases)
|
137
162
|
data = []
|
163
|
+
|
138
164
|
test_cases.each do |tc|
|
139
165
|
|
140
166
|
status_value = TestRailOperations.status_rspec_to_testrail(tc.status)
|
@@ -156,11 +182,11 @@ module TestRailRSpecIntegration
|
|
156
182
|
end
|
157
183
|
|
158
184
|
if data.size > 0
|
159
|
-
TestRailOperations.post_run_results(
|
185
|
+
TestRailOperations.post_run_results(@@run_id, data)
|
160
186
|
test_case_ids = test_cases.collect { |tc| tc.id }
|
161
|
-
|
187
|
+
puts "Successfully posted results for testcases: #{test_case_ids} to test run: #{@@run_id}"
|
162
188
|
else
|
163
|
-
|
189
|
+
puts "No results sent to test rail"
|
164
190
|
end
|
165
191
|
end
|
166
192
|
|
@@ -169,6 +195,7 @@ module TestRailRSpecIntegration
|
|
169
195
|
alias_method :example_failed, :example_finished
|
170
196
|
|
171
197
|
private
|
198
|
+
|
172
199
|
# For pushing results up to a test plan in TestRail.
|
173
200
|
def is_for_test_rail_plan
|
174
201
|
!ENV["TESTRAIL_RUN"].nil? && !ENV["TESTRAIL_PLAN_ID"].nil? && !ENV["TESTRAIL_ENTRY_ID"].nil? && !ENV["TESTRAIL_ENTRY_RUN_ID"].nil?
|
@@ -370,6 +397,15 @@ module TestRailRSpecIntegration
|
|
370
397
|
if add_formatter
|
371
398
|
TestRailRSpecIntegration.add_formatter_for(config)
|
372
399
|
end
|
400
|
+
|
401
|
+
# Captures and posts results for any remaining test case results in @@cases that don't fill a full batch
|
402
|
+
config.after(:suite) do |suite|
|
403
|
+
total_cases = TestRailPlanFormatter.class_variable_get(:@@cases)
|
404
|
+
|
405
|
+
if total_cases.size > 0
|
406
|
+
TestRailRSpecIntegration::TestRailPlanFormatter.post_results total_cases
|
407
|
+
end
|
408
|
+
end
|
373
409
|
end
|
374
410
|
|
375
411
|
# Registers a callback custom formatter to an rspec. The new test run is created from
|
data/lib/files/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testrailtagging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.8.
|
4
|
+
version: 0.3.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.5.2.3
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Utilities for working with testrail.
|