1
votes

I have a single feature in my solution as follows:

Feature: Login
The login screen
Scenario Outline: Logging in with invalid credentials
Given A user account has been created and activated
When I enter the username < username >
And I enter the password < password >
And I press Login
Then An error message is displayed
Examples:
| username | password |
| joe.bloggs | abcd1234 |
| known.user | ck |

The steps file contains:

[Binding]
public class LoginSteps
{

    [Given(@"A user account has been created and activated")]
    public void GivenAUserAccountHasBeenCreatedAndActivated()
    {
        int a = 1;
    }

    [When(@"When I enter the username (.*)")]
    public void WhenIEnterTheUsername(string username)
    {
        int a = 1;
    }

    [When(@"When I enter the password (.*)")]
    public void WhenIEnterThePassword(string password)
    {
        int a = 1;
    }

    [When(@"I press Login")]
    public void WhenIPressLogin()
    {
        int a = 1;
    }

    [Then(@"An error message is displayed")]
    public void ThenAnErrorMessageIsDisplayed()
    {
        int a = 1;
    }
}

*i've added the 'int a = 1;' lines temporarily to keep it simple for debugging

When I right click on the feature and select 'Debug Specflow Scenarios' the following error occurs: No matching step definition found for one or more steps : 'An error message is displayed'

The scenario is all colour coded correctly and Go to step definition works for the 'An error message is displayed' step.

Anyone else seen this before or got any suggestions on how to fix?

3
Sorry, i pasted in the wrong steps code originally. Have now replaced with correct code.Paul Green
Could you please fix the formatting of the Scenario?Andreas Willich

3 Answers

1
votes

Problem is probably in the config-file of your specflow-project... Did you: a) Not declare a testrunner b) Declare a non-english language?

or alternative c) Accidentily disable specflow d) Have the wrong dotnet-framework selected

1
votes

In the end the only way I could fix it was to delete the feature file and recreate it from scratch. Works now but I don't know exactly what the problem was.

1
votes

The problem you are having is that the when steps have the word when repeated as in:

 [When(@"When I enter the username (.*)")]
....

 [When(@"When I enter the password (.*)")]

They should be like so:

    [When(@"I enter the username (.*)")]
    public void WhenIEnterTheUsername(string username)
    {
        int a = 1;
    }

    [When(@"I enter the password (.*)")]
    public void WhenIEnterThePassword(string password)
    {
        int a = 1;
    }