Skip to content

Commit

Permalink
Merge pull request sj26#86 from pingfr/error_count
Browse files Browse the repository at this point in the history
Added support to read outside error count returned from XML formatter.
  • Loading branch information
sj26 authored Apr 2, 2020
2 parents 3738c28 + 3641d00 commit 35bcf25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec_junit_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def xml_dump
output << %{ tests="#{example_count}"}
output << %{ skipped="#{pending_count}"}
output << %{ failures="#{failure_count}"}
output << %{ errors="0"}
output << %{ errors="#{error_count}"}
output << %{ time="#{escape("%.6f" % duration)}"}
output << %{ timestamp="#{escape(started.iso8601)}"}
output << %{ hostname="#{escape(Socket.gethostname)}"}
Expand Down
4 changes: 4 additions & 0 deletions lib/rspec_junit_formatter/rspec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def failure_for(example)
"#{message}\n#{backtrace.join("\n")}"
end

def error_count
0
end

def find_shared_group(example)
group_and_parent_groups(example).find { |group| group.metadata[:shared_group_name] }
end
Expand Down
9 changes: 9 additions & 0 deletions lib/rspec_junit_formatter/rspec3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ def examples
@examples_notification.notifications
end

def error_count
# Introduced in rspec 3.6
if @summary_notification.respond_to?(:errors_outside_of_examples_count)
@summary_notification.errors_outside_of_examples_count
else
0
end
end

def result_of(notification)
notification.example.execution_result.status
end
Expand Down

0 comments on commit 35bcf25

Please sign in to comment.