sj26/rspec_junit_formatter

Handle multiple failures in aggregate_failures block

TimAle opened this issue · 2 comments

RSpec 3.3 allows to group multiple failures using aggregrate_failures, but formatter doesn't not handle it. It just puts

<testcase classname="spec.sample_test" name="test with aggregate_failures with multiple failures" file="./spec/sample_test.rb" time="0.037076"><failure message="RSpec::Expectations::MultipleExpectationsNotMetError" type="RSpec::Expectations::MultipleExpectationsNotMetError">
./spec/sample_test.rb:4:in `block (2 levels) in &lt;top (required)&gt;&apos;</failure></testcase>

when RSpec output is

Failures:

  1) test with aggregate_failures with multiple failures
     Got 3 failures from failure aggregation block "multiple failures".
     # ./spec/sample_test.rb:4:in `block (2 levels) in <top (required)>'

     1.1) Failure/Error: expect(0).to eq 1

            expected: 1
                 got: 0

            (compared using ==)
          # ./spec/sample_test.rb:5:in `block (3 levels) in <top (required)>'

     1.2) Failure/Error: expect(2).to eq 3

            expected: 3
                 got: 2

            (compared using ==)
          # ./spec/sample_test.rb:6:in `block (3 levels) in <top (required)>'

     1.3) Failure/Error: expect(4).to eq 5

            expected: 5
                 got: 4

            (compared using ==)
          # ./spec/sample_test.rb:7:in `block (3 levels) in <top (required)>'

Is there a way to handle it?

We got exactly the same issue, what's the Issue/PR status?

This had been a minor annoyance for us for a while and as it happens I finally got around to looking into and implementing a fix yesterday. See PR #74 for my patch. I ended up leveraging the same fully_formatted_lines method as in PR #58.