Skip to content

Commit

Permalink
Merge pull request #89 from simpsonjulian/testcase-summary
Browse files Browse the repository at this point in the history
Add testcase count to output
  • Loading branch information
toolmantim authored Feb 14, 2019
2 parents 458f3cf + 5eedd9f commit f38a5d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ruby/bin/annotate
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Failure < Struct.new(:name, :failed_test, :body, :job, :type)
end

junit_report_files = Dir.glob(File.join(junits_dir, "**", "*"))
testcases = 0
failures = []

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

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

STDERR.puts "--- ❓ Checking failures"
STDERR.puts "#{testcases} testcases found"

if failures.empty?
STDERR.puts "There were no failures/errors 🙌"
Expand Down
8 changes: 8 additions & 0 deletions ruby/tests/annotate_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Parsing junit-2.xml
Parsing junit-3.xml
--- ❓ Checking failures
8 testcases found
There were no failures/errors 🙌
OUTPUT

Expand All @@ -24,6 +25,7 @@
Parsing junit-2.xml
Parsing junit-3.xml
--- ❓ Checking failures
6 testcases found
There are 4 failures/errors 😭
--- ✍️ Preparing annotation
4 failures:
Expand Down Expand Up @@ -108,6 +110,7 @@
Parsing junit-2.xml
Parsing junit-3.xml
--- ❓ Checking failures
6 testcases found
There are 4 failures/errors 😭
--- ✍️ Preparing annotation
2 failures and 2 errors:
Expand Down Expand Up @@ -190,6 +193,7 @@
assert_equal <<~OUTPUT, output
Parsing junit-123-456-custom-pattern.xml
--- ❓ Checking failures
2 testcases found
There is 1 failure/error 😭
--- ✍️ Preparing annotation
1 failure:
Expand Down Expand Up @@ -223,6 +227,7 @@
Parsing junit-2.xml
Parsing junit-3.xml
--- ❓ Checking failures
6 testcases found
There are 4 failures/errors 😭
--- ✍️ Preparing annotation
2 failures and 2 errors:
Expand Down Expand Up @@ -307,6 +312,7 @@
Parsing sub-dir/junit-2.xml
Parsing sub-dir/junit-3.xml
--- ❓ Checking failures
6 testcases found
There are 4 failures/errors 😭
--- ✍️ Preparing annotation
4 failures:
Expand Down Expand Up @@ -389,6 +395,7 @@
assert_equal <<~OUTPUT, output
Parsing junit.xml
--- ❓ Checking failures
2 testcases found
There is 1 failure/error 😭
--- ✍️ Preparing annotation
1 failure:
Expand All @@ -408,6 +415,7 @@
assert_equal <<~OUTPUT, output
Parsing junit.xml
--- ❓ Checking failures
2 testcases found
There is 1 failure/error 😭
--- ✍️ Preparing annotation
1 error:
Expand Down

0 comments on commit f38a5d3

Please sign in to comment.