Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show details for failing examples tagged with aggregate_failures: true #108

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

skaestle
Copy link

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: &quot;foo&quot;

     (compared using ==)

     ./spec/example_spec.rb:53:in `block (2 levels) in &lt;top (required)&gt;'

  2) expected: 2
          got: &quot;bar&quot;

     (compared using ==)

     ./spec/example_spec.rb:54:in `block (2 levels) in &lt;top (required)&gt;'</failure>
     </testcase>
</testsuite>

@skaestle
Copy link
Author

skaestle commented Oct 7, 2024

hi there @sj26. any chance you could have a look at this PR? we have this code running on our CI (gitlab) for awhile and we have yet to see any adverse side-effects

Let me know if there is anything to help get this PR into the main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant