blob: cd34dbaf62f7960747a58b25b1acca60c8a1d79d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
|
require 'spec_helper'
describe Gitlab::Ci::Reports::TestSuite do
include TestReportsHelper
let(:test_suite) { described_class.new('Rspec') }
let(:test_case_success) { create_test_case_rspec_success }
let(:test_case_failed) { create_test_case_rspec_failed }
let(:test_case_skipped) { create_test_case_rspec_skipped }
let(:test_case_error) { create_test_case_rspec_error }
it { expect(test_suite.name).to eq('Rspec') }
describe '#add_test_case' do
context 'when status of the test case is success' do
it 'stores data correctly' do
test_suite.add_test_case(test_case_success)
expect(test_suite.test_cases[test_case_success.status][test_case_success.key])
.to eq(test_case_success)
expect(test_suite.total_time).to eq(1.11)
end
end
context 'when status of the test case is failed' do
it 'stores data correctly' do
test_suite.add_test_case(test_case_failed)
expect(test_suite.test_cases[test_case_failed.status][test_case_failed.key])
.to eq(test_case_failed)
expect(test_suite.total_time).to eq(2.22)
end
end
context 'when two test cases are added' do
it 'sums up total time' do
test_suite.add_test_case(test_case_success)
test_suite.add_test_case(test_case_failed)
expect(test_suite.total_time).to eq(3.33)
end
end
end
describe '#total_count' do
subject { test_suite.total_count }
before do
test_suite.add_test_case(test_case_success)
test_suite.add_test_case(test_case_failed)
end
it { is_expected.to eq(2) }
end
describe '#total_status' do
subject { test_suite.total_status }
context 'when all test cases succeeded' do
before do
test_suite.add_test_case(test_case_success)
end
it { is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS) }
end
context 'when a test case failed' do
before do
test_suite.add_test_case(test_case_success)
test_suite.add_test_case(test_case_failed)
end
it { is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED) }
end
end
Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status_type|
describe "##{status_type}" do
subject { test_suite.public_send("#{status_type}") }
context "when #{status_type} test case exists" do
before do
test_suite.add_test_case(public_send("test_case_#{status_type}"))
end
it 'returns all success test cases' do
is_expected.to eq( { public_send("test_case_#{status_type}").key => public_send("test_case_#{status_type}") })
end
end
context "when #{status_type} test case do not exist" do
it 'returns nothing' do
is_expected.to be_empty
end
end
end
end
Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status_type|
describe "##{status_type}_count" do
subject { test_suite.public_send("#{status_type}_count") }
context "when #{status_type} test case exists" do
before do
test_suite.add_test_case(public_send("test_case_#{status_type}"))
end
it 'returns the count' do
is_expected.to eq(1)
end
end
context "when #{status_type} test case do not exist" do
it 'returns nothing' do
is_expected.to be(0)
end
end
end
end
end
|