[VisualStudio Extension] Support binding inheritance or fix VS IntelliSense for external assemblies
Hello,
I'm trying to use SpecFlow to test product on two levels - API and UI. I have one set of Features for both API and UI tests and three assemblies,Product.Tests.SharedSteps.dll
, Product.Tests.API.dll
and Product.Tests.UI.dll
. What I'm trying to achieve is to have an abstract class in Product.Tests.SharedSteps.dll
defining steps on API level such as:
[Binding] public abstract class SharedStepsBase { [When("I add an item X")] public virtual void IAddAnItemX() { // add an item via API } // more steps here ... }
Then in Product.Tests.API.dll
I'll have a class:
[Binding] public class APISteps : SharedStepsBase { // all steps in SharedStepsBase are using API so we are good here }
Then I want to change some of the API steps to go through UI for UI tests. So I create a class in Product.Tests.UI.dll
:
[Binding] public class UISteps : SharedStepsBase { public override void IAddAnItemX() { // add an item via UI } // rest of steps stays via API }
so that UI steps can use some steps from API level but can also override some steps with different implementation going through UI.
When I try to run API or UI tests it fails with error Ambiguous step definitions found for step 'When I add an item X'
.
Looking at SpecFlow code it's kind of expected, it scans all [Binding]
classes for steps and it finds same step in SharedStepsBase
and in APISteps
/UISteps
classes because they inherit from it.
So I tried to remove Product.Tests.SharedSteps
from app.config
<stepAssemblies>
section for Product.Tests.UI/API
. That solved "ambiguous step" errors because now SpecFlow does not look for steps in Product.Tests.SharedSteps
when running tests. So far so good. But then I opened .feature
file and all steps from SharedStepsBase
are purple, SpecFlow VS plugin does not know them.
Second thing I tried was to leave Product.Tests.SharedSteps
in <stepAssemblies>
but remove [Binding]
attribute from it. That also removes "ambiguous step" errors but it still breaks IntelliSense.
So I can either have binding inheritance if I don't put base class assembly to <stepAssemblies>
, but then IntelliSense is not working, or I can have working IntelliSense but then I can't inherit from an abstract class with steps in another assembly.
Would it be possible to either ignore steps in abstract class and read them only from child class so that there are no duplicate steps? Or would it be possible to fix VS plugin so that it can read steps from base class not marked with [Binding]
?
Please sign in to leave a comment.
Comments
0 comments