Skip to content

Commit f38a5d3

Browse files
authored
Merge pull request #89 from simpsonjulian/testcase-summary
Add testcase count to output
2 parents 458f3cf + 5eedd9f commit f38a5d3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

ruby/bin/annotate

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Failure < Struct.new(:name, :failed_test, :body, :job, :type)
2020
end
2121

2222
junit_report_files = Dir.glob(File.join(junits_dir, "**", "*"))
23+
testcases = 0
2324
failures = []
2425

2526
def text_content(element)
@@ -41,6 +42,7 @@ junit_report_files.sort.each do |file|
4142
doc = REXML::Document.new(xml)
4243

4344
REXML::XPath.each(doc, '//testsuite//testcase') do |testcase|
45+
testcases += 1
4446
name = testcase.attributes['name'].to_s
4547
failed_test = testcase.attributes[failure_format].to_s
4648
testcase.elements.each("failure") do |failure|
@@ -53,6 +55,7 @@ junit_report_files.sort.each do |file|
5355
end
5456

5557
STDERR.puts "--- ❓ Checking failures"
58+
STDERR.puts "#{testcases} testcases found"
5659

5760
if failures.empty?
5861
STDERR.puts "There were no failures/errors 🙌"

ruby/tests/annotate_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Parsing junit-2.xml
1111
Parsing junit-3.xml
1212
--- ❓ Checking failures
13+
8 testcases found
1314
There were no failures/errors 🙌
1415
OUTPUT
1516

@@ -24,6 +25,7 @@
2425
Parsing junit-2.xml
2526
Parsing junit-3.xml
2627
--- ❓ Checking failures
28+
6 testcases found
2729
There are 4 failures/errors 😭
2830
--- ✍️ Preparing annotation
2931
4 failures:
@@ -108,6 +110,7 @@
108110
Parsing junit-2.xml
109111
Parsing junit-3.xml
110112
--- ❓ Checking failures
113+
6 testcases found
111114
There are 4 failures/errors 😭
112115
--- ✍️ Preparing annotation
113116
2 failures and 2 errors:
@@ -190,6 +193,7 @@
190193
assert_equal <<~OUTPUT, output
191194
Parsing junit-123-456-custom-pattern.xml
192195
--- ❓ Checking failures
196+
2 testcases found
193197
There is 1 failure/error 😭
194198
--- ✍️ Preparing annotation
195199
1 failure:
@@ -223,6 +227,7 @@
223227
Parsing junit-2.xml
224228
Parsing junit-3.xml
225229
--- ❓ Checking failures
230+
6 testcases found
226231
There are 4 failures/errors 😭
227232
--- ✍️ Preparing annotation
228233
2 failures and 2 errors:
@@ -307,6 +312,7 @@
307312
Parsing sub-dir/junit-2.xml
308313
Parsing sub-dir/junit-3.xml
309314
--- ❓ Checking failures
315+
6 testcases found
310316
There are 4 failures/errors 😭
311317
--- ✍️ Preparing annotation
312318
4 failures:
@@ -389,6 +395,7 @@
389395
assert_equal <<~OUTPUT, output
390396
Parsing junit.xml
391397
--- ❓ Checking failures
398+
2 testcases found
392399
There is 1 failure/error 😭
393400
--- ✍️ Preparing annotation
394401
1 failure:
@@ -408,6 +415,7 @@
408415
assert_equal <<~OUTPUT, output
409416
Parsing junit.xml
410417
--- ❓ Checking failures
418+
2 testcases found
411419
There is 1 failure/error 😭
412420
--- ✍️ Preparing annotation
413421
1 error:

0 commit comments

Comments
 (0)