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

ParallelTests::Cucumber::FailuresLogger is broken #979

Open
codener opened this issue Dec 13, 2024 · 2 comments
Open

ParallelTests::Cucumber::FailuresLogger is broken #979

codener opened this issue Dec 13, 2024 · 2 comments

Comments

@codener
Copy link

codener commented Dec 13, 2024

ParallelTests::Cucumber::FailuresLogger seems to be broken, at least for parallel_tests v3.8.1 with cucumber v7.1.0 and parallel_tests v4.7.2 with cucumber v9.2.0. It brings a #done method that does the right thing, but that method is never called. Instead, on test run completion, a callback inherited from Cucumber::Formatter::Rerun is executed. Since that was not written for parallelism, it improperly joins failure locations without a space, rendering the failures log file useless.

# Broken failure log
$ cat tmp/cucumber_failures.log
features/a.feature:3features/another.feature:3

A working patch looks like this:

# Monkey patch
class ParallelTests::Cucumber::FailuresLogger

  def initialize(config)
    super
    patch_handlers(config) # <-- Added
    @io = prepare_io(config.out_stream)
  end

  def patch_handlers(config)
    # Remove handler inherited from Cucumber::Formatter::Rerun
    handlers = config.event_bus.instance_variable_get(:@handlers)
    handlers['Cucumber::Events::TestRunFinished'].pop

    config.on_event :test_run_finished do
      done
    end
  end

end

I assume, Cucumber would need an official option to either remove an event handler, or to prevent one from being added.

wdyt?

@grosser
Copy link
Owner

grosser commented Dec 14, 2024

patch looks alright, make sure to add a test that fails without it first :)
and most of this issues description as inline comment to explain what is going on

@codener
Copy link
Author

codener commented Dec 16, 2024

Ok nice. Will provide a patch, probably next year.

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

No branches or pull requests

2 participants