Skip to content

Commit

Permalink
misc: Prevent overriding set by test example aggregate_failures flag (#…
Browse files Browse the repository at this point in the history
…2975)

## Context

Recently we're added by default `aggregate_failures: true` to all test's
metadata.
Unfortunately, `aggregate_failures` changes some information on the test
example metadata and limits our opportunity to debug randomly failing
test more efficiently.

Particularly this overrides `example.exception`. It's needed when we
have test that fails from time to time depending on some tricky data
combination.

The quickest and easiest known way to me to debug it is to use `after {
|example| binding.pry if example.exception }`. That callback will
trigger breakpoint only if test failed.

quick debug setup will look like
```ruby
describe "something" do
  after { |example| binding.pry if example.exception }

  1000.times do
  fit "randomly failing test", aggregate_failures: false do
    # ....
  end
  end
end
```

That will run the same test many times and trigger breakpoint only when
it's worth to check by us.


## Description

Adjusting metadata setup to respect values set directly on test.
  • Loading branch information
floganz authored Dec 18, 2024
1 parent b3e378c commit 16b2400
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
end

config.define_derived_metadata do |meta|
meta[:aggregate_failures] = true
unless meta.key?(:aggregate_failures)
meta[:aggregate_failures] = true
end
end
end

0 comments on commit 16b2400

Please sign in to comment.