rspec_junit_formatter
rspec_junit_formatter copied to clipboard
show details for failing examples tagged with `aggregate_failures: true`
This will fix Issue #56 and was heavily inspired by #74 and all credit for the specs go to @jasoncodes
It outputs the exception.message
in the case of a RSpec::Expectations::MultipleExpectationsNotMetError
. This emulates what Core::Formatters::JsonFormatter
does: https://github.com/rspec/rspec-core/blob/main/lib/rspec/core/formatters/json_formatter.rb#L43
Before
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="rspec" tests="1" skipped="0" failures="1" errors="0" time="0.014878" timestamp="2024-09-10T10:30:24+02:00" hostname="GREM-C02C90V3MD6V.local">
<properties>
<property name="seed" value="12345"/>
</properties>
<testcase classname="spec.example_spec" name="some example specs should support multiple failures" file="./spec/example_spec.rb" time="0.013631"><failure message="RSpec::Expectations::MultipleExpectationsNotMetError" type="RSpec::Expectations::MultipleExpectationsNotMetError">
</failure></testcase>
</testsuite>
After
<?xml version="1.0" encoding="UTF-8"?>
<testsuite errors="0" failures="1" hostname="GREM-C02C90V3MD6V.local" name="rspec" skipped="0" tests="1" time="0.010382" timestamp="2024-09-10T10:31:22+02:00">
<properties>
<property name="seed" value="12345"/>
</properties>
<testcase classname="spec.example_spec" file="./spec/example_spec.rb" name="some example specs should support multiple failures" time="0.009463">
<failure message="RSpec::Expectations::MultipleExpectationsNotMetError" type="RSpec::Expectations::MultipleExpectationsNotMetError">Got 2 failures from failure aggregation block:
1) expected: 1
got: "foo"
(compared using ==)
./spec/example_spec.rb:53:in `block (2 levels) in <top (required)>'
2) expected: 2
got: "bar"
(compared using ==)
./spec/example_spec.rb:54:in `block (2 levels) in <top (required)>'</failure>
</testcase>
</testsuite>