Skip to content

Update MessageBuilder when runner generate messages#1882

Draft
brasmusson wants to merge 22 commits into
mainfrom
feature/runner-messages
Draft

Update MessageBuilder when runner generate messages#1882
brasmusson wants to merge 22 commits into
mainfrom
feature/runner-messages

Conversation

@brasmusson

@brasmusson brasmusson commented May 31, 2026

Copy link
Copy Markdown
Contributor

Description

  • Changes when the runner generate messages at the source.

Depend on cucumber/cucumber-ruby-core#331

Type of change

Please delete options that are not relevant.

  • Refactoring (improvements to code design or tooling that don't change behaviour)
  • New feature (non-breaking change which adds new behaviour)

Please add an entry to the relevant section of CHANGELOG.md as part of this pull request.

Checklist:

Your PR is ready for review once the following checklist is
complete. You can also add some checks if you want to.

  • Tests have been added for any changes to behaviour of the code
  • New and existing tests are passing locally and on CI
  • bundle exec rubocop reports no offenses
  • RDoc comments have been updated
  • CHANGELOG.md has been updated

luke-hill and others added 4 commits April 7, 2026 19:21
* Delete a portion of the RSpec double verification that is not auto enabled

* Add in a bit of a split for some of the glue code
* Remove ruby 2.1 patch

* Moved top level errors out of runtime to bespoke errors file

* Re-order errors according to names

* Re-order requires and pivot to more optimal require relatives

* Tidy up of rubocop autogen file
Base automatically changed from feature/v11_message_emittence_at_source to main June 1, 2026 19:51
luke-hill and others added 18 commits June 19, 2026 13:41
* Remove all references to strict

* Fix up missing spec issue from strict mode

* Remove strict from default options

* Dry run with undefined scenarios will still pass as undefined is a permissible item

* Add warning for retry_failing_tests invalid failure

* Fix up retry_failing_tests to be more conformant now

* Clean up rerun formatter

* Fix erroneous message class

* Remove erroneous scenario

* Update the junit_formatter.feature for the strict removal

* When strict is removed, test cases with pending and undefined steps
  will always be reported as failed by the junit formatter.

* Remove redundant scenario

* Switch in v17 of core and fix up missing constants

---------

Co-authored-by: Björn Rasmusson <B.Rasmusson@computer.org>
* When strict is removed from cucumber-ruby-core pending and undefined
  steps will fail the test run (the exit code will be non-zero).
* Changes when the runner generate test_case_started/finished messages
  at the source.
* Changes when the runner generate test_step_started/finished messages
  at the source.
* Pass also the id_generator to the runner.
@brasmusson
brasmusson changed the base branch from main to v11/deletions July 16, 2026 08:44
@brasmusson
brasmusson force-pushed the feature/runner-messages branch from 4007e67 to 402b6ea Compare July 16, 2026 08:45
return unless event.envelope.test_case_started

@current_test_case_started_id = event.envelope.test_case_started.id
@current_test_run_hook_started_id = nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding doesn't this "reset" always need to happen. Then line 60 can become

@current_test_case_started_id = event.envelope.test_case_started.id if event.envelope.test_case_started

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is equivalent to write line 58-63 as:

        if event.envelope.test_case_started
          @current_test_case_started_id = event.envelope.test_case_started.id
          @current_test_run_hook_started_id = nil
          @repository.update(event.envelope)
        end

but rubocop will complain "Use a guard clause (return unless event.envelope.test_case_started) instead of wrapping the code inside a conditional expression."

Another equivalent alternative is

        @current_test_case_started_id = event.envelope.test_case_started.id if event.envelope.test_case_started
        @current_test_run_hook_started_id = nil if event.envelope.test_case_started
        @repository.update(event.envelope) if event.envelope.test_case_started

but I'm not sure about using the same trailing if on three lines in a row.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I more meant this.

@current_test_case_started_id = event.envelope.test_case_started.id if event.envelope.test_case_started
@current_test_run_hook_started_id = nil
@repository.update(event.envelope)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@current_test_run_hook_started_id = nil
is completely wrong. What you get if you inline store_current_test_run_hook_started_id and snip the line that are not relevant is:

@current_test_run_hook_started_id = event.envelope.test_run_hook_started.id if event.envelope.test_run_hook_started

@current_test_run_hook_started_id = nil

@repository.update(event.envelope) is not completely wrong, but it is not necessary to update the repository with every type of message. Actually since the only usage of the repository in message_builder is:
@repository.test_step_by_id[event.test_step.id].pickle_step_id
(in generate_snippet_envelope)
@repository.update(event.envelope) is not needed at all here. It is sufficient that the repository is updated with the test_case_ready envelopes in on_test_case_ready.

This should also work:

@current_test_case_started_id = event.envelope.test_case_started.id if event.envelope.test_case_started
@current_test_run_hook_started_id = nil if event.envelope.test_case_started

@luke-hill

Copy link
Copy Markdown
Contributor

Requires cucumber-core 18.1+

Base automatically changed from v11/deletions to main July 20, 2026 13:27
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.

2 participants