Reqnroll icon indicating copy to clipboard operation
Reqnroll copied to clipboard

Add `RuleInfo` to `ScenarioContext`

Open loraderon opened this issue 1 year ago • 7 comments

🤔 What's changed?

Added RuleInfo to ScenarioContext.

RuleInfo will be null if no Rule is parsed.

⚡️ What's your motivation?

#452

🏷️ What kind of change is this?

  • :zap: New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

📋 Checklist:

  • [x] I've changed the behaviour of the code
    • [x] I have added/updated tests to cover my changes.
  • [x] My change requires a change to the documentation.
    • [x] I have updated the documentation accordingly.
  • [x] Users should know about my change
    • [x] I have added an entry to the "[vNext]" section of the CHANGELOG, linking to this pull request & included my GitHub handle to the release contributors list.

This text was originally taken from the template of the Cucumber project, then edited by hand. You can modify the template here.

loraderon avatar Feb 13 '25 10:02 loraderon

Awesome change, I'm curious how you would go about hooking this into NUnit3 to show as the name?

HeathLoganCampbell avatar Feb 14 '25 11:02 HeathLoganCampbell

Just had a quick scan and it looks good, but I will do a more detailed review later. Please check the failing unit tests.

One thing that I didn't get: Why to you need the changes you had in the ObjectContainer.cs?

gasparnagy avatar Feb 14 '25 13:02 gasparnagy

Please check the failing unit tests.

My bad, that shouldn't have slipped through. I have issues with the xunit tests timing out locally so I deactivated some tests.

One thing that I didn't get: Why to you need the changes you had in the ObjectContainer.cs?

Because we want RuleInfo to be null when there is no rule defined (*). I encountered errors when I didn't register anything for RuleInfo, and it wasn't possible to implicitly register anything as null. To address this, I added an explicit method (RegisterNull). I'm open to suggestions if there's another way to allow null for RuleInfo.


* I believe that RuleInfo should be null if no rule is defined because Rule is nullable in ScenarioDefinitionInFeatureFile.

loraderon avatar Feb 14 '25 14:02 loraderon

Because we want RuleInfo to be null when there is no rule defined (*). I encountered errors when I didn't register anything for RuleInfo, and it wasn't possible to implicitly register anything as null. To address this, I added an explicit method (RegisterNull). I'm open to suggestions if there's another way to allow null for RuleInfo.

Thx for the clarification. Tricky indeed. I will think about that and give feedback.

gasparnagy avatar Feb 14 '25 14:02 gasparnagy

@gasparnagy Thank you for the feedback, I made the changes you suggested. 👍

However I'm not really sure about the required changes to the Windsor test Resolved_scenario_context_is_the_same_for_the_same_scenario_container. Without explicitly registering a RuleInfo instance in the test it fails with Reqnroll.BoDi.ObjectContainerException : Primitive types or structs cannot be resolved: System.String (resolution path: Reqnroll.ScenarioContext->Reqnroll.RuleInfo).

Do you have any pointers here?

loraderon avatar Mar 06 '25 09:03 loraderon

Do you have any pointers here?

Please change the line https://github.com/reqnroll/Reqnroll/blob/8c7c78a9c96fdc1b444ebd4844434d46aa248659/Tests/Reqnroll.PluginTests/Windsor/WindsorPluginTests.cs?plain=1#L82C1-L82C124

scenarioContainer.RegisterInstanceAs(new ScenarioInfo("", "", Array.Empty<string>(), new OrderedDictionary()));

with registering a new SecnarioContext instance:

scenarioContainer.RegisterInstanceAs(new ScenarioContext(..., new ScenarioInfo("", "", Array.Empty<string>(), new OrderedDictionary())..., ));

gasparnagy avatar Mar 06 '25 15:03 gasparnagy

Maybe we could fix the breaking changes in the interfaces with default interface implementations? (And mark the old ones as [Obsolete] with a good message)

304NotModified avatar Mar 13 '25 18:03 304NotModified

@loraderon Thank you for the contribution! According to our guidelines I have invited you to the Reqnroll "contributors team". Congrats! 🎉 If you accept it, you will be able to make pull requests easier in the future.

You are also welcome on our discord server: https://go.reqnroll.net/discord-invite

gasparnagy avatar May 27 '25 07:05 gasparnagy