Question

Is it possible to have two step definition classes with first being in one namespace/project, and second in another one? I have like this:

My test project which I run: namespace: ABZ.ExcelTest class name: ABZ.ExcelTest.ExcelStepDefinition

My other project which is Logic for testing: namespace: ABZ.OfficeAddInTestLogic class name: ABZ.OfficeAddInTestLogic.StepDefinition

I have [Binding] attribute on both my classes but this one which is not in test project (ABZ.OfficeAddInTestLogic.StepDefinition) cannot be found, I get NUnit error:

No matching step definition found for the step. Use the following code to create one: ...

Is it possible to have 2 step definition classes in different projects?

Was it helpful?

Solution

Yes it is - that feature is called External steps (see https://github.com/techtalk/SpecFlow/blob/master/Tests/FeatureTests/ExternalSteps/ExternalSteps.feature)

What you probably are missing is an app.config setting like this:

<specFlow>  
<stepAssemblies>
  <stepAssembly assembly="ExternalStepsCS" />
</stepAssemblies>

That will look for steps in an external assembly called ExternalStepsCS in this case.

OTHER TIPS

I will often have a "Test Helpers" library, with common code shared between multiple test projects. I'll have a class in this shared library, let's call it CucumberBase. Then, in my actual test project, I'll have a class like this:

[Binding]
public class SomeFeatureSpecs : CucumberBase
{
    ...
}

Every public CucumberBase method that is tagged with [Given()]/[When()]/[Then()]/etc. gets picked up correctly in my actual test project, within the SomeFeatureSpecs class. This lets me override and extend common functionality as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top