Reputation: 4645
I have a specflow Feature file with the following When
When Request for servername 'someurl.com/szhm04c4.xml' is processed
When I press F12
Visual Studio tells me that I can copy the following Step-Definition:
[When(@"Request for servername '(.*)' is processed")]
public void WhenRequestForServernameIsProcessed(string p0)
{
ScenarioContext.Current.Pending();
}
I paste this to my step-file which inherits from Steps
and implement it
public void WhenRequestForServernameIsProcessed(string servername)
{
var httpRequest = this.Bootstrapper.GetFake<IHttpRequest>();
A.CallTo(() => httpRequest.Path).Returns(servername);
var httpContext = this.Bootstrapper.Get<IHttpContext>();
this.Bootstrapper.Get<IHostRequest>().Process(httpContext);
}
When I execute the test, it fials and I get following error message:
TechTalk.SpecFlow.SpecFlowException Test pending: No matching step definition found for one or more steps. using System; using TechTalk.SpecFlow;
namespace MyNamespace { [Binding] public class StepDefinitions { [When(@"Request for servername '(.*)' is processed")] public void WhenRequestForServernameIsProcessed(string p0) { ScenarioContext.Current.Pending(); } } }
Why is that? I did define this step...
Thanks in advance
Upvotes: 2
Views: 8798
Reputation: 1
Make sure you build the project after creating the feature file and step defs. When you build it, a .cs file will create as a part of your feature file and that Binds to your step definition
Upvotes: 0
Reputation: 11
Make sure that:
If the test is in a separate assembly:
Not that you cannot have multiple [Binding] classes with the same name (even if a different namespace) or specflow will be confused and may not find your steps.
Upvotes: 0
Reputation: 5835
You have to put the [Binding] Attribute to the class, so that SpecFlow can find your steps.
Upvotes: 8