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

Prevent mutations on world parameters leaking between test cases #2362

Merged
merged 4 commits into from Dec 21, 2023

Conversation

davidjgoss
Copy link
Contributor

@davidjgoss davidjgoss commented Dec 21, 2023

πŸ€” What's changed?

Clone the world parameters before creating each world instance. This prevents user code that updates the world parameters from leaking those changes across different test cases.

Also, type the worldParameters as JsonObject in configuration to enforce it should be JSON serialisable.

It would have been nice to somehow ensure immutability even between hooks/steps in the same test case. But realistically, users can have custom world instances, they can do what they want with the parameters object they are passed, so there's only so much we can do as the orchestrator.

⚑️ What's your motivation?

Fixes #2356

🏷️ What kind of change is this?

  • πŸ› Bug fix (non-breaking change which fixes a defect)

πŸ“‹ Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@coveralls
Copy link

coveralls commented Dec 21, 2023

Coverage Status

coverage: 98.383%. remained the same
when pulling e093602 on fix/world-parameters-immutable
into 052ac1a on main.

@davidjgoss davidjgoss merged commit 2a95e47 into main Dec 21, 2023
6 checks passed
@davidjgoss davidjgoss deleted the fix/world-parameters-immutable branch December 21, 2023 14:32
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.

world parameters are mutable from scenarios, and changes leak to other scenarios
2 participants