test_rail_integration 0.0.8.1 → 0.0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_rail_integration/generator/connection.rb +1 -39
- data/lib/test_rail_integration/generator/project/check.rb +24 -11
- data/lib/test_rail_integration/generator/test_case_result.rb +87 -7
- data/lib/test_rail_integration/generator/test_rail_hooks.rb +2 -34
- data/lib/test_rail_integration/version.rb +1 -1
- data/spec/api_calls_spec.rb +31 -0
- data/spec/check_test_run_spec.rb +43 -17
- data/spec/hooks_spec.rb +125 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc5cbef07f354e0d32aa921ae232a51994faf657
|
4
|
+
data.tar.gz: b30b50310e51039182a2419f486a77dbbe421a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 888b1a1edff070819afd93b279c8506a8656ab3baf99958c17945bc9498371cfeac1dda88ea46abcea3a7e2befc2ed0d7431cbfe9175cf6c48ed7fde8b26bced
|
7
|
+
data.tar.gz: 84c180ac6ee8100369b6c70c759029eecd434764a77890f47b43fceccf3d191ed0205e30c415f108a1759975c33828744822f632f7dcf03f9818aa9adfab0b58
|
@@ -38,7 +38,7 @@ module TestRail
|
|
38
38
|
#
|
39
39
|
# client.send_get("get_results_for_case/12/3534")
|
40
40
|
#
|
41
|
-
def self.
|
41
|
+
def self.get_test_results(case_id)
|
42
42
|
client.send_get("get_results_for_case/#{test_run_id}/#{case_id}")
|
43
43
|
end
|
44
44
|
|
@@ -49,44 +49,6 @@ module TestRail
|
|
49
49
|
client.send_post("add_run/#{project_id}", {suite_id: test_suite_id, name: name, include_all: false, case_ids: cases_with_types})
|
50
50
|
end
|
51
51
|
|
52
|
-
#
|
53
|
-
# Parse results and returns Failed if this test was marked as failed.
|
54
|
-
#
|
55
|
-
def self.get_previous_test_result(case_id)
|
56
|
-
test_results = get_test_result(case_id).map { |status_hash| status_hash["status_id"] }
|
57
|
-
status = TestCaseResult::FAILED if test_results.include?(TestCaseResult::FAILED)
|
58
|
-
status ||= TestCaseResult::PASS if test_results.first == TestCaseResult::PASS
|
59
|
-
status ||= TestCaseResult::NEW
|
60
|
-
status
|
61
|
-
end
|
62
|
-
|
63
|
-
#
|
64
|
-
# Parse results and returns previous comment.
|
65
|
-
#
|
66
|
-
def self.get_previous_comments(case_id)
|
67
|
-
test_comment = get_test_result(case_id).map { |hash| hash["comment"] }
|
68
|
-
comment = test_comment
|
69
|
-
comment ||= []
|
70
|
-
comment
|
71
|
-
end
|
72
|
-
|
73
|
-
#
|
74
|
-
# Get indexes of failed results
|
75
|
-
#
|
76
|
-
def self.get_indexes_of_fails(test_case_id)
|
77
|
-
indexes = get_test_result(test_case_id).map.with_index { |result, index| result["status_id"] == TestCaseResult::COMMENT[:fail][:status] ? index : nil }
|
78
|
-
indexes.compact
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
# Get last failed comment for test case
|
83
|
-
#
|
84
|
-
def self.get_last_failed_comment(test_case_id)
|
85
|
-
comments = get_previous_comments(test_case_id)
|
86
|
-
index = Connection.get_indexes_of_fails(test_case_id).first
|
87
|
-
comments[index]
|
88
|
-
end
|
89
|
-
|
90
52
|
#
|
91
53
|
# Get ID of all test cases from current test run
|
92
54
|
#
|
@@ -7,29 +7,30 @@ module TestRail
|
|
7
7
|
|
8
8
|
class Check
|
9
9
|
|
10
|
-
|
11
10
|
def self.check_test_run_statuses
|
12
11
|
start_time = Time.new
|
13
12
|
results = []
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
test_cases_ids = Connection.cases_with_types
|
15
|
+
test_cases_ids.each do |test_case_id|
|
16
|
+
|
17
|
+
case_info = Connection.get_case_info(test_case_id)
|
18
|
+
scenario = Scenario.new(case_info['title'], ["@C#{test_case_id}"])
|
19
|
+
test_case_result = TestRail::TestCaseResult.new(scenario)
|
20
|
+
test_results = test_case_result.test_results.map { |status_hash| status_hash["status_id"] }
|
17
21
|
|
18
|
-
test_results
|
19
|
-
|
20
|
-
fail_indexes = test_results.map.with_index{ |element, index| element == TestCaseResult::COMMENT[:fail][:status] ? index : nil }.compact
|
21
|
-
pass_indexes = test_results.map.with_index{ |element, index| element == TestCaseResult::COMMENT[:pass][:status] ? index : nil }.compact
|
22
|
+
if test_results.include?(TestCaseResult::COMMENT[:fail][:status]) &&
|
23
|
+
test_results.include?(TestCaseResult::COMMENT[:pass][:status])
|
22
24
|
|
23
|
-
if
|
24
|
-
scenario = Connection.get_case_info(test_case)
|
25
|
-
test_case_result = TestRail::TestCaseResult.new(test_case, scenario['title'])
|
25
|
+
if test_case_result.get_indexes_of_passes.first < test_case_result.get_indexes_of_fails.first
|
26
26
|
test_case_result.comment ||= TestRail::TestCaseResult::COMMENT[:fail]
|
27
27
|
TestRail::Connection.commit_test_result(test_case_result)
|
28
28
|
|
29
29
|
p test_case_result.test_case_id
|
30
|
-
p test_case_result.title
|
30
|
+
p test_case_result.scenario.title
|
31
31
|
results.push(test_case_result)
|
32
32
|
end
|
33
|
+
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end_time = Time.now - start_time
|
@@ -38,4 +39,16 @@ module TestRail
|
|
38
39
|
end
|
39
40
|
|
40
41
|
end
|
42
|
+
|
43
|
+
class Scenario
|
44
|
+
|
45
|
+
attr_accessor :title, :source_tag_names
|
46
|
+
|
47
|
+
def initialize(title, source_tag_names)
|
48
|
+
self.title = title
|
49
|
+
self.source_tag_names = source_tag_names
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
41
54
|
end
|
@@ -3,7 +3,13 @@ require_relative 'test_rail_data_load'
|
|
3
3
|
module TestRail
|
4
4
|
class TestCaseResult
|
5
5
|
|
6
|
-
attr_accessor :test_case_id,
|
6
|
+
attr_accessor :test_case_id,
|
7
|
+
:comment,
|
8
|
+
:exception_message,
|
9
|
+
:assign_to,
|
10
|
+
:previous_comment,
|
11
|
+
:scenario,
|
12
|
+
:test_results
|
7
13
|
|
8
14
|
COMMENT_STATUS ||= TestRail::TestRailDataLoad.test_rail_data[:status_comment]
|
9
15
|
PASS ||= TestRail::TestRailDataLoad.test_rail_data[:test_pass]
|
@@ -13,16 +19,90 @@ module TestRail
|
|
13
19
|
FAILED_COMMENT ||= TestRail::TestRailDataLoad.test_rail_data[:test_failed_comment]
|
14
20
|
ASSIGN_TO ||= TestRail::TestRailDataLoad.test_rail_data[:assign_to]
|
15
21
|
|
16
|
-
|
17
22
|
COMMENT ||= {:pass => {status: PASS, comment: PASS_COMMENT},
|
18
23
|
:fail => {status: FAILED, comment: FAILED_COMMENT},
|
19
24
|
:unchanged_pass => {status: COMMENT_STATUS, comment: PASS_COMMENT}
|
20
25
|
}
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
self.
|
27
|
+
TEST_RAIL_ID_REGEX ||= /^@C\d+/
|
28
|
+
|
29
|
+
def initialize(scenario)
|
30
|
+
self.test_case_id = scenario.source_tag_names.find { |e| e.match(TEST_RAIL_ID_REGEX) }[2..-1]
|
31
|
+
self.scenario = scenario
|
32
|
+
self.test_results = TestRail::Connection.get_test_results(self.test_case_id)
|
33
|
+
self.previous_comment = get_last_failed_comment unless get_indexes_of_fails.empty?
|
34
|
+
end
|
35
|
+
|
36
|
+
def failed?
|
37
|
+
!scenario.passed?
|
38
|
+
end
|
39
|
+
|
40
|
+
def passed?
|
41
|
+
scenario.passed? && get_previous_test_result != FAILED
|
42
|
+
end
|
43
|
+
|
44
|
+
def unchanged_pass?
|
45
|
+
scenario.passed? && get_previous_test_result == FAILED
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# Get indexes of failed results
|
50
|
+
#
|
51
|
+
def get_indexes_of_fails
|
52
|
+
indexes = self.test_results.map.with_index { |result, index| result["status_id"] == TestCaseResult::COMMENT[:fail][:status] ? index : nil }
|
53
|
+
indexes.compact
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_indexes_of_passes
|
57
|
+
indexes = self.test_results.map.with_index { |result, index| result["status_id"] == TestCaseResult::COMMENT[:pass][:status] ? index : nil }
|
58
|
+
indexes.compact
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Parse results and returns previous comment.
|
63
|
+
#
|
64
|
+
def get_previous_comments
|
65
|
+
test_comment = self.test_results.map { |hash| hash["comment"] }
|
66
|
+
comment = test_comment
|
67
|
+
comment ||= []
|
68
|
+
comment
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Get last failed comment for test case
|
73
|
+
#
|
74
|
+
def get_last_failed_comment
|
75
|
+
comments = get_previous_comments
|
76
|
+
index = get_indexes_of_fails.first
|
77
|
+
comments[index]
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Parse results and returns Failed if this test was marked as failed.
|
82
|
+
#
|
83
|
+
def get_previous_test_result
|
84
|
+
test_results = self.test_results.map { |status_hash| status_hash["status_id"] }
|
85
|
+
status = FAILED if test_results.include?(FAILED)
|
86
|
+
status ||= PASS if test_results.first == PASS
|
87
|
+
status ||= NEW
|
88
|
+
status
|
89
|
+
end
|
90
|
+
|
91
|
+
def update
|
92
|
+
self.comment = COMMENT[:pass] if passed?
|
93
|
+
self.comment ||= COMMENT[:unchanged_pass] if unchanged_pass?
|
94
|
+
|
95
|
+
if failed?
|
96
|
+
self.comment ||= COMMENT[:fail]
|
97
|
+
self.exception_message = scenario.steps.exception rescue nil
|
98
|
+
self.assign_to = ASSIGN_TO
|
99
|
+
end
|
100
|
+
|
101
|
+
raise("Invalid test case result : scenario.passed? #{self.scenario.passed?}, prev_result? #{get_previous_test_result}, run_result? #{self.scenario.passed?}") if self.comment.nil?
|
102
|
+
|
103
|
+
TestRail::Connection.commit_test_result(self)
|
104
|
+
|
105
|
+
self
|
26
106
|
end
|
27
107
|
|
28
108
|
#
|
@@ -31,7 +111,7 @@ module TestRail
|
|
31
111
|
# {status_id: 1, comment: "Test passed"}
|
32
112
|
#
|
33
113
|
def to_test_rail_api
|
34
|
-
comment_message = "#{self.comment[:comment]} \"#{self.title}\""
|
114
|
+
comment_message = "#{self.comment[:comment]} \"#{self.scenario.title}\""
|
35
115
|
comment_message = "**[#{Fixtures.instance['venture']}]** #{self.comment[:comment]} for \"#{self.title}\"" unless defined?(Fixtures.instance['venture']).nil?
|
36
116
|
comment_message += "\n Exception : #{self.exception_message}" unless self.exception_message.nil?
|
37
117
|
comment_message += "\n #{self.previous_comment}" if self.comment[:status] == COMMENT[:fail][:status] || self.comment[:status] == COMMENT[:unchanged_pass][:status]
|
@@ -3,47 +3,15 @@ require 'test_rail_integration/generator/connection'
|
|
3
3
|
module TestRail
|
4
4
|
class Hook
|
5
5
|
|
6
|
-
TEST_RAIL_ID_REGEX ||= /^@C\d+/
|
7
|
-
|
8
6
|
#
|
9
7
|
# Updating Test Rail according to logic
|
10
8
|
#
|
11
9
|
def self.update_test_rail(scenario)
|
12
|
-
|
13
|
-
|
14
|
-
prev_result = TestRail::Connection.get_previous_test_result(test_case_id)
|
15
|
-
run_result = scenario.passed?
|
16
|
-
test_case_result = TestRail::TestCaseResult.new(test_case_id, scenario.title)
|
17
|
-
|
18
|
-
test_case_result.comment = TestRail::TestCaseResult::COMMENT[:pass] if passed_result?(run_result, prev_result)
|
19
|
-
test_case_result.comment ||= TestRail::TestCaseResult::COMMENT[:unchanged_pass] if unchanged_pass_result?(run_result, prev_result)
|
20
|
-
|
21
|
-
if failed_result?(run_result)
|
22
|
-
test_case_result.comment ||= TestRail::TestCaseResult::COMMENT[:fail]
|
23
|
-
test_case_result.exception_message = scenario.steps.exception rescue nil
|
24
|
-
test_case_result.assign_to = TestRail::TestCaseResult::ASSIGN_TO
|
25
|
-
end
|
26
|
-
|
27
|
-
raise("Invalid test case result : scenario.passed? #{scenario.passed?}, prev_result? #{prev_result}, run_result? #{run_result}") if test_case_result.comment.nil?
|
28
|
-
|
29
|
-
TestRail::Connection.commit_test_result(test_case_result)
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.failed_result?(result)
|
34
|
-
!result
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.passed_result?(result, prev_result)
|
38
|
-
result && prev_result != TestRail::TestCaseResult::FAILED
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.unchanged_pass_result?(result, prev_result)
|
42
|
-
result && prev_result == TestRail::TestCaseResult::FAILED
|
10
|
+
TestRail::TestCaseResult.new(scenario).update
|
43
11
|
end
|
44
12
|
|
45
13
|
at_exit do
|
46
|
-
TestRail::Connection.change_test_run_name
|
14
|
+
TestRail::Connection.change_test_run_name until ENV['rspec-tests-running']
|
47
15
|
end
|
48
16
|
end
|
49
17
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require_relative '../lib/test_rail_integration/generator/connection'
|
3
|
+
|
4
|
+
describe 'Api calls' do
|
5
|
+
|
6
|
+
context 'When i am creating test case result' do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
allow(TestRail::Connection).to receive(:commit_test_result).and_return('good!')
|
10
|
+
@scenario = double('scenario')
|
11
|
+
allow(@scenario).to receive(:source_tag_names).and_return(['@C4556'])
|
12
|
+
allow(@scenario).to receive(:title).and_return('title')
|
13
|
+
allow(@scenario).to receive(:passed?).and_return(true)
|
14
|
+
allow(TestRail::Connection).to receive(:get_test_results).and_return([])
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'i am calling get_test_results api method once' do
|
18
|
+
expect(TestRail::Connection).to receive(:get_test_results).once
|
19
|
+
test_case_result = TestRail::TestCaseResult.new(@scenario)
|
20
|
+
test_case_result.update
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'i am calling commit_test_result api method once' do
|
24
|
+
expect(TestRail::Connection).to receive(:commit_test_result).once
|
25
|
+
test_case_result = TestRail::TestCaseResult.new(@scenario)
|
26
|
+
test_case_result.update
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/spec/check_test_run_spec.rb
CHANGED
@@ -4,29 +4,55 @@ require_relative '../lib/test_rail_integration/generator/project/check'
|
|
4
4
|
|
5
5
|
describe 'Checking test run' do
|
6
6
|
|
7
|
-
context 'when last result is pass
|
7
|
+
context 'when last result is pass' do
|
8
|
+
|
9
|
+
context 'but we already have one result' do
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
allow(TestRail::Connection).to receive(:cases_with_types).and_return([1011])
|
13
|
+
allow(TestRail::Connection).to receive(:get_test_results).and_return([{"status_id" => 1, :comment => "FTW"}, {"status_id" => 5, :comment => "Burn heretics"}])
|
14
|
+
allow(TestRail::Connection).to receive(:get_case_info).and_return({id: 1011, "title" => 'MLP'})
|
15
|
+
allow(TestRail::Connection).to receive(:commit_test_result).and_return([])
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should change status to fail' do
|
19
|
+
test_case_results = TestRail::Check.check_test_run_statuses
|
20
|
+
expect(test_case_results[0].comment).to eq({:status => 5, :comment => "test **failed:**"})
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should call api once' do
|
24
|
+
expect(TestRail::Connection).to receive(:cases_with_types).once
|
25
|
+
expect(TestRail::Connection).to receive(:get_case_info).once
|
26
|
+
expect(TestRail::Connection).to receive(:get_test_results).once
|
27
|
+
expect(TestRail::Connection).to receive(:commit_test_result).once
|
28
|
+
TestRail::Check.check_test_run_statuses
|
29
|
+
end
|
8
30
|
|
9
|
-
|
31
|
+
end
|
10
32
|
|
11
|
-
|
12
|
-
allow(TestRail::Connection).to receive(:get_test_result).and_return([{"status_id" => 1, :comment => "FTW"}, {"status_id" => 5, :comment => "Burn heretics"}])
|
13
|
-
allow(TestRail::Connection).to receive(:get_case_info).and_return({id: 1011, "title" => 'MLP'})
|
14
|
-
allow(TestRail::Connection).to receive(:commit_test_result).and_return([])
|
33
|
+
context 'but we already have several results' do
|
15
34
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
35
|
+
before(:each) do
|
36
|
+
allow(TestRail::Connection).to receive(:cases_with_types).and_return([1011, 1213])
|
37
|
+
allow(TestRail::Connection).to receive(:get_test_results).and_return([{"status_id" => 1, :comment => "FTW"}, {"status_id" => 5, :comment => "Burn heretics"}] )
|
38
|
+
allow(TestRail::Connection).to receive(:get_case_info).and_return({id: 1011, "title" => 'MLP'})
|
39
|
+
allow(TestRail::Connection).to receive(:commit_test_result).and_return([])
|
40
|
+
end
|
20
41
|
|
21
|
-
|
42
|
+
it 'should have two results' do
|
43
|
+
test_case_results = TestRail::Check.check_test_run_statuses
|
44
|
+
expect(test_case_results.length).to eq 2
|
45
|
+
end
|
22
46
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
47
|
+
it 'should call api twice' do
|
48
|
+
expect(TestRail::Connection).to receive(:cases_with_types).once
|
49
|
+
expect(TestRail::Connection).to receive(:get_case_info).twice
|
50
|
+
expect(TestRail::Connection).to receive(:get_test_results).twice
|
51
|
+
expect(TestRail::Connection).to receive(:commit_test_result).twice
|
52
|
+
TestRail::Check.check_test_run_statuses
|
53
|
+
end
|
27
54
|
|
28
|
-
test_case_results = TestRail::Check.check_test_run_statuses
|
29
|
-
expect(test_case_results.length).to eq 2
|
30
55
|
end
|
56
|
+
|
31
57
|
end
|
32
58
|
end
|
data/spec/hooks_spec.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require_relative '../lib/test_rail_integration/generator/connection'
|
3
|
+
require_relative '../lib/test_rail_integration/generator/test_rail_hooks'
|
4
|
+
|
5
|
+
describe 'Update test results' do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
ENV['rspec-tests-running'] = '1'
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
allow(TestRail::Connection).to receive(:commit_test_result).and_return('good!')
|
13
|
+
@scenario = double('scenario')
|
14
|
+
allow(@scenario).to receive(:source_tag_names).and_return(['@C4556'])
|
15
|
+
allow(@scenario).to receive(:title).and_return('title')
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when there is no previous result' do
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
allow(TestRail::Connection).to receive(:get_test_results).and_return([])
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'current result should be passed' do
|
25
|
+
test_result = TestRail::Hook.update_test_rail(passed_scenario)
|
26
|
+
expect(test_result.test_case_id).to eq('4556')
|
27
|
+
expect(test_result.comment).to eq({:status=>1, :comment => 'test **passed:**'})
|
28
|
+
expect(test_result.to_test_rail_api).to eq({:status_id => 1, :comment => "test **passed:** \"title\""})
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'current result should be failed' do
|
32
|
+
test_result = TestRail::Hook.update_test_rail(failed_scenario)
|
33
|
+
expect(test_result.test_case_id).to eq('4556')
|
34
|
+
expect(test_result.comment).to eq({:status=>5, :comment => 'test **failed:**'})
|
35
|
+
expect(test_result.to_test_rail_api).to eq({:status_id => 5, :comment => "test **failed:** \"title\"\n Exception : exception\n "})
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when previous result is passed' do
|
41
|
+
|
42
|
+
before(:each) do
|
43
|
+
allow(TestRail::Connection).to receive(:get_test_results).and_return(
|
44
|
+
[{"status_id" => 1, "comment" =>"test **passed:**"}])
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'current result should be passed' do
|
48
|
+
test_result = TestRail::Hook.update_test_rail(passed_scenario)
|
49
|
+
expect(test_result.test_case_id).to eq('4556')
|
50
|
+
expect(test_result.comment).to eq({:status=>1, :comment => 'test **passed:**'})
|
51
|
+
expect(test_result.to_test_rail_api).to eq({:status_id => 1, :comment => "test **passed:** \"title\""})
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'current result should be failed' do
|
55
|
+
test_result = TestRail::Hook.update_test_rail(failed_scenario)
|
56
|
+
expect(test_result.test_case_id).to eq('4556')
|
57
|
+
expect(test_result.comment).to eq({:status=>5, :comment => 'test **failed:**'})
|
58
|
+
expect(test_result.to_test_rail_api).to eq({:status_id => 5, :comment => "test **failed:** \"title\"\n Exception : exception\n "})
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when previous result is failed' do
|
64
|
+
|
65
|
+
before(:each) do
|
66
|
+
allow(TestRail::Connection).to receive(:get_test_results).and_return(
|
67
|
+
[{"status_id" => 5, "comment" =>"test **failed:**"}])
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'current result should be failed' do
|
71
|
+
test_result = TestRail::Hook.update_test_rail(failed_scenario)
|
72
|
+
expect(test_result.test_case_id).to eq('4556')
|
73
|
+
expect(test_result.comment).to eq({:status=>5, :comment => 'test **failed:**'})
|
74
|
+
expect(test_result.to_test_rail_api).to eq({:status_id => 5, :comment => "test **failed:** \"title\"\n Exception : exception\n test **failed:**"})
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'current result should be comment' do
|
78
|
+
test_result = TestRail::Hook.update_test_rail(passed_scenario)
|
79
|
+
expect(test_result.test_case_id).to eq('4556')
|
80
|
+
expect(test_result.comment).to eq({:status=>0, :comment => 'test **passed:**'})
|
81
|
+
expect(test_result.to_test_rail_api).to eq({:comment => "test **passed:** \"title\"\n test **failed:**"})
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when previous result is comment' do
|
87
|
+
|
88
|
+
before(:each) do
|
89
|
+
allow(TestRail::Connection).to receive(:get_test_results).and_return(
|
90
|
+
[{"status_id" => 5, "comment" =>"test **failed:**"}])
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'current result should be comment' do
|
94
|
+
allow(@scenario).to receive(:passed?).and_return(true)
|
95
|
+
test_result = TestRail::Hook.update_test_rail(passed_scenario)
|
96
|
+
expect(test_result.test_case_id).to eq('4556')
|
97
|
+
expect(test_result.comment).to eq({:status=>0, :comment => 'test **passed:**'})
|
98
|
+
expect(test_result.to_test_rail_api).to eq({:comment => "test **passed:** \"title\"\n test **failed:**"})
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'current result should be failed' do
|
102
|
+
test_result = TestRail::Hook.update_test_rail(failed_scenario)
|
103
|
+
expect(test_result.test_case_id).to eq('4556')
|
104
|
+
expect(test_result.comment).to eq({:status=>5, :comment => 'test **failed:**'})
|
105
|
+
expect(test_result.to_test_rail_api).to eq({:status_id => 5, :comment => "test **failed:** \"title\"\n Exception : exception\n test **failed:**"})
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
def passed_scenario
|
112
|
+
allow(@scenario).to receive(:passed?).and_return(true)
|
113
|
+
@scenario
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
def failed_scenario
|
118
|
+
allow(@scenario).to receive(:passed?).and_return(false)
|
119
|
+
steps = double('steps')
|
120
|
+
allow(steps).to receive(:exception).and_return('exception')
|
121
|
+
allow(@scenario).to receive(:steps).and_return(steps)
|
122
|
+
@scenario
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_rail_integration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.8.
|
4
|
+
version: 0.0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirikami
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -179,7 +179,9 @@ files:
|
|
179
179
|
- lib/test_rail_integration/generator/test_run_creation.rb
|
180
180
|
- lib/test_rail_integration/generator/test_run_parameters.rb
|
181
181
|
- lib/test_rail_integration/version.rb
|
182
|
+
- spec/api_calls_spec.rb
|
182
183
|
- spec/check_test_run_spec.rb
|
184
|
+
- spec/hooks_spec.rb
|
183
185
|
- spec/spec_helper.rb
|
184
186
|
- test_rail_integration.gemspec
|
185
187
|
homepage: https://github.com/Kirikami/test_rail_integration
|
@@ -207,5 +209,7 @@ signing_key:
|
|
207
209
|
specification_version: 4
|
208
210
|
summary: Gem for integration between framework and TestRail API
|
209
211
|
test_files:
|
212
|
+
- spec/api_calls_spec.rb
|
210
213
|
- spec/check_test_run_spec.rb
|
214
|
+
- spec/hooks_spec.rb
|
211
215
|
- spec/spec_helper.rb
|