SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.24k stars 754 forks source link

Report binding problems to binding registry and show them as errors during test execution #2663

Closed gasparnagy closed 1 year ago

gasparnagy commented 1 year ago

Some generic binding errors (e.g. [Binding] on a generic type) were not properly reported as errors so far, only as warnings, but those are usually not visible by test runners. Some of these errors were causing strange exceptions during execution, but it was hard to trace them back to the source problem.

Also type load exceptions blocked the discovery process that causes problems with tooling (e.g. VS) that uses the binding registry builder to discover the step definitions.

This PR introduces validity of loaded binding registry and provides a way to query these errors from the binding registry. During test execution, the invalid binding registry fails the tests by listing all collected error.

Types of changes

Checklist:

gasparnagy commented 1 year ago

@SabotageAndi the PR exposes a tuple on the IBindingRegistry interface (IEnumerable<(BindingErrorType ErrorType, string Message)> GetErrorMessages();) I don't know if this is a good practice, or whether we should create a new type for that. What do you think?

SabotageAndi commented 1 year ago

I would not put a tuple into a public interface. Feels wrong for me.

gasparnagy commented 1 year ago

@SabotageAndi OK, I agree. I will fix it

gasparnagy commented 1 year ago

@SabotageAndi pushed a new version without the tuple

SabotageAndi commented 1 year ago

@gasparnagy Ready to merge?

gasparnagy commented 1 year ago

@SabotageAndi yes, done.