Skip to content

Commit fe9254d

Browse files
authored
Merge pull request #15 from martinbaillie/master
Handle multiple JUnit test suites per file
2 parents e71d9cc + c20d2b0 commit fe9254d

File tree

6 files changed

+222
-9
lines changed

6 files changed

+222
-9
lines changed

ruby/bin/annotate

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ junit_report_files.each do |file|
2626
xml = File.read(file)
2727
doc = REXML::Document.new(xml)
2828

29-
doc.elements.each('*/testcase') do |testcase|
29+
REXML::XPath.each(doc, '//testsuite//testcase') do |testcase|
3030
name = testcase.attributes['name'].to_s
3131
classname = testcase.attributes['classname'].to_s
3232
testcase.elements.each("failure") do |failure|
@@ -66,4 +66,4 @@ failures.each do |failure|
6666
end
6767
puts "</details>"
6868
puts "" unless failure == failures.last
69-
end
69+
end

ruby/tests/annotate_test.rb

Lines changed: 113 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
assert_equal <<~OUTPUT, output
99
Parsing junit-1.xml
10+
Parsing junit-3.xml
1011
Parsing junit-2.xml
1112
--- ❓ Checking failures
1213
There were no failures/errors 🙌
@@ -20,11 +21,12 @@
2021

2122
assert_equal <<~OUTPUT, output
2223
Parsing junit-1.xml
24+
Parsing junit-3.xml
2325
Parsing junit-2.xml
2426
--- ❓ Checking failures
25-
There are 2 failures/errors 😭
27+
There are 4 failures/errors 😭
2628
--- ✍️ Preparing annotation
27-
2 failures:
29+
4 failures:
2830
2931
<details>
3032
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
@@ -57,6 +59,40 @@
5759
./spec/support/log.rb:17:in `run'
5860
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
5961
62+
in <a href="#3">Job #3</a>
63+
</details>
64+
65+
<details>
66+
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
67+
68+
<code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
69+
70+
expected: 250
71+
got: 500
72+
73+
(compared using eql?)
74+
./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>'
75+
./spec/support/database.rb:16:in `block (2 levels) in <top (required)>'
76+
./spec/support/log.rb:17:in `run'
77+
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
78+
79+
in <a href="#3">Job #3</a>
80+
</details>
81+
82+
<details>
83+
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ in spec.models.account_spec</code></summary>
84+
85+
<code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
86+
87+
expected: 700
88+
got: 500
89+
90+
(compared using eql?)
91+
./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>'
92+
./spec/support/database.rb:16:in `block (2 levels) in <top (required)>'
93+
./spec/support/log.rb:17:in `run'
94+
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
95+
6096
in <a href="#2">Job #2</a>
6197
</details>
6298
OUTPUT
@@ -69,11 +105,12 @@
69105

70106
assert_equal <<~OUTPUT, output
71107
Parsing junit-1.xml
108+
Parsing junit-3.xml
72109
Parsing junit-2.xml
73110
--- ❓ Checking failures
74-
There are 2 failures/errors 😭
111+
There are 4 failures/errors 😭
75112
--- ✍️ Preparing annotation
76-
1 failure and 1 error:
113+
2 failures and 2 errors:
77114
78115
<details>
79116
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
@@ -106,6 +143,40 @@
106143
./spec/support/log.rb:17:in `run'
107144
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
108145
146+
in <a href="#3">Job #3</a>
147+
</details>
148+
149+
<details>
150+
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
151+
152+
<code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
153+
154+
expected: 250
155+
got: 500
156+
157+
(compared using eql?)
158+
./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>'
159+
./spec/support/database.rb:16:in `block (2 levels) in <top (required)>'
160+
./spec/support/log.rb:17:in `run'
161+
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
162+
163+
in <a href="#3">Job #3</a>
164+
</details>
165+
166+
<details>
167+
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ in spec.models.account_spec</code></summary>
168+
169+
<code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
170+
171+
expected: 700
172+
got: 500
173+
174+
(compared using eql?)
175+
./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>'
176+
./spec/support/database.rb:16:in `block (2 levels) in <top (required)>'
177+
./spec/support/log.rb:17:in `run'
178+
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
179+
109180
in <a href="#2">Job #2</a>
110181
</details>
111182
OUTPUT
@@ -149,11 +220,12 @@
149220

150221
assert_equal <<~OUTPUT, output
151222
Parsing sub-dir/junit-1.xml
223+
Parsing sub-dir/junit-3.xml
152224
Parsing sub-dir/junit-2.xml
153225
--- ❓ Checking failures
154-
There are 2 failures/errors 😭
226+
There are 4 failures/errors 😭
155227
--- ✍️ Preparing annotation
156-
2 failures:
228+
4 failures:
157229
158230
<details>
159231
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
@@ -186,10 +258,44 @@
186258
./spec/support/log.rb:17:in `run'
187259
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
188260
261+
in <a href="#3">Job #3</a>
262+
</details>
263+
264+
<details>
265+
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
266+
267+
<code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
268+
269+
expected: 250
270+
got: 500
271+
272+
(compared using eql?)
273+
./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>'
274+
./spec/support/database.rb:16:in `block (2 levels) in <top (required)>'
275+
./spec/support/log.rb:17:in `run'
276+
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
277+
278+
in <a href="#3">Job #3</a>
279+
</details>
280+
281+
<details>
282+
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ in spec.models.account_spec</code></summary>
283+
284+
<code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
285+
286+
expected: 700
287+
got: 500
288+
289+
(compared using eql?)
290+
./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>'
291+
./spec/support/database.rb:16:in `block (2 levels) in <top (required)>'
292+
./spec/support/log.rb:17:in `run'
293+
./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code>
294+
189295
in <a href="#2">Job #2</a>
190296
</details>
191297
OUTPUT
192298

193299
assert_equal 0, status.exitstatus
194300
end
195-
end
301+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="rspec" tests="2" skipped="0" failures="0" errors="0" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
4+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ" file="./spec/models/account_spec.rb" time="0.020013"/>
5+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 900 if the account is F00" file="./spec/models/account_spec.rb" time="0.020013"/>
6+
</testsuite>
7+
<testsuite name="rspec" tests="2" skipped="0" failures="0" errors="0" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
8+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 500 if the account is ABC" file="./spec/models/account_spec.rb" time="0.020013"/>
9+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 250 by default" file="./spec/models/account_spec.rb" time="0.967127"/>
10+
</testsuite>
11+
</testsuites>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="rspec" tests="1" skipped="0" failures="1" errors="0" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
4+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ" file="./spec/models/account_spec.rb" time="0.967127">
5+
<failure message=" expected: 700 got: 500 (compared using eql?) " type="RSpec::Expectations::ExpectationNotMetError">Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
6+
7+
expected: 700
8+
got: 500
9+
10+
(compared using eql?)
11+
./spec/models/account_spec.rb:78:in `block (3 levels) in &lt;top (required)&gt;&apos;
12+
./spec/support/database.rb:16:in `block (2 levels) in &lt;top (required)&gt;&apos;
13+
./spec/support/log.rb:17:in `run&apos;
14+
./spec/support/log.rb:66:in `block (2 levels) in &lt;top (required)&gt;&apos;</failure>
15+
</testcase>
16+
</testsuite>
17+
<testsuite name="rspec" tests="2" skipped="0" failures="0" errors="1" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
18+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 500 if the account is ABC" file="./spec/models/account_spec.rb" time="0.020013"/>
19+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 250 by default" file="./spec/models/account_spec.rb" time="0.967127">
20+
<error message=" expected: 250 got: 500 (compared using eql?) " type="RSpec::Expectations::ExpectationNotMetError">Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
21+
22+
expected: 250
23+
got: 500
24+
25+
(compared using eql?)
26+
./spec/models/account_spec.rb:78:in `block (3 levels) in &lt;top (required)&gt;&apos;
27+
./spec/support/database.rb:16:in `block (2 levels) in &lt;top (required)&gt;&apos;
28+
./spec/support/log.rb:17:in `run&apos;
29+
./spec/support/log.rb:66:in `block (2 levels) in &lt;top (required)&gt;&apos;</error>
30+
</testcase>
31+
</testsuite>
32+
</testsuites>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="rspec" tests="1" skipped="0" failures="1" errors="0" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
4+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ" file="./spec/models/account_spec.rb" time="0.967127">
5+
<failure message=" expected: 700 got: 500 (compared using eql?) " type="RSpec::Expectations::ExpectationNotMetError">Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
6+
7+
expected: 700
8+
got: 500
9+
10+
(compared using eql?)
11+
./spec/models/account_spec.rb:78:in `block (3 levels) in &lt;top (required)&gt;&apos;
12+
./spec/support/database.rb:16:in `block (2 levels) in &lt;top (required)&gt;&apos;
13+
./spec/support/log.rb:17:in `run&apos;
14+
./spec/support/log.rb:66:in `block (2 levels) in &lt;top (required)&gt;&apos;</failure>
15+
</testcase>
16+
</testsuite>
17+
<testsuite name="rspec" tests="2" skipped="0" failures="1" errors="0" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
18+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 500 if the account is ABC" file="./spec/models/account_spec.rb" time="0.020013"/>
19+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 250 by default" file="./spec/models/account_spec.rb" time="0.967127">
20+
<failure message=" expected: 250 got: 500 (compared using eql?) " type="RSpec::Expectations::ExpectationNotMetError">Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
21+
22+
expected: 250
23+
got: 500
24+
25+
(compared using eql?)
26+
./spec/models/account_spec.rb:78:in `block (3 levels) in &lt;top (required)&gt;&apos;
27+
./spec/support/database.rb:16:in `block (2 levels) in &lt;top (required)&gt;&apos;
28+
./spec/support/log.rb:17:in `run&apos;
29+
./spec/support/log.rb:66:in `block (2 levels) in &lt;top (required)&gt;&apos;</failure>
30+
</testcase>
31+
</testsuite>
32+
</testsuites>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="rspec" tests="1" skipped="0" failures="1" errors="0" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
4+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ" file="./spec/models/account_spec.rb" time="0.967127">
5+
<failure message=" expected: 700 got: 500 (compared using eql?) " type="RSpec::Expectations::ExpectationNotMetError">Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
6+
7+
expected: 700
8+
got: 500
9+
10+
(compared using eql?)
11+
./spec/models/account_spec.rb:78:in `block (3 levels) in &lt;top (required)&gt;&apos;
12+
./spec/support/database.rb:16:in `block (2 levels) in &lt;top (required)&gt;&apos;
13+
./spec/support/log.rb:17:in `run&apos;
14+
./spec/support/log.rb:66:in `block (2 levels) in &lt;top (required)&gt;&apos;</failure>
15+
</testcase>
16+
</testsuite>
17+
<testsuite name="rspec" tests="2" skipped="0" failures="1" errors="0" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
18+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 500 if the account is ABC" file="./spec/models/account_spec.rb" time="0.020013"/>
19+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 250 by default" file="./spec/models/account_spec.rb" time="0.967127">
20+
<failure message=" expected: 250 got: 500 (compared using eql?) " type="RSpec::Expectations::ExpectationNotMetError">Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250)
21+
22+
expected: 250
23+
got: 500
24+
25+
(compared using eql?)
26+
./spec/models/account_spec.rb:78:in `block (3 levels) in &lt;top (required)&gt;&apos;
27+
./spec/support/database.rb:16:in `block (2 levels) in &lt;top (required)&gt;&apos;
28+
./spec/support/log.rb:17:in `run&apos;
29+
./spec/support/log.rb:66:in `block (2 levels) in &lt;top (required)&gt;&apos;</failure>
30+
</testcase>
31+
</testsuite>
32+
</testsuites>

0 commit comments

Comments
 (0)