2

I'm getting this error: Ambiguous Step Definition Found For Step.... on running my Specflow Test. The code is for the client, that I'm working for, thus I'm not permitted to provide code sample.

However, let me give you a background into what I'm doing and the particular issues, that I'm running into at the moment.

The code is referring to a Given statement in my Feature File. I have checked this website and searched over the Internet as well for possible solutions.

So far, I have found some pointers, but no solution yet.

They are:

  1. https://stackoverflow.com/questions/38598385/ambiguous-step-definitions-when-try-to-implement-in-generic-fashion-c-specflow

  2. https://stackoverflow.com/questions/30846370/specflow-ambiguity-in-bindings

  3. https://stackoverflow.com/questions/13763502/specflow-ambiguous-step-definitions-found-for-step-when-1-step-has-more-par

3
  • May be it is worth providing some representative example that does not resemble the real code but spots the same issue?
    – Alexey R.
    Commented Jan 31, 2018 at 9:04
  • @AlexeyR... Thanks for the comment. What I have in the Steps Definition File is: [Given(@"I have GMail Account")] public void GivenIHaveGMailAccount() { ScenarioContext.Current.Pending(); }
    – OA345
    Commented Jan 31, 2018 at 9:09
  • I have edited the code so that it is not a replica of the code that I am working on. Thanks
    – OA345
    Commented Jan 31, 2018 at 9:11

1 Answer 1

1

Specflow generates nunit tests from the gerkhin feature files by generating a code behind file. This process is often quite sketchy and sometimes creates broken files. If you delete the .cs file with the same name as the .feature file it should get regenerated.

Be aware that specflow doesn't work on dotnet core , only framework.

It doesn't work particularly well in anything that isn't visual studio either.

I have often spent hours chasing whitespace around to ensure that the regexes that are used to match the steps work correctly. If you are having trouble with these I would recommend pasting them into regex101.com with the subroutine names, this site will explain what the regex matches in the context of the example data you give it.

4
  • Thanks for the response. I have deleted the file, but I have not been able to re-generate it. I tried re-starting and refreshing the project. It still does not generate the file. Your thoughts are welcome. Thank you
    – OA345
    Commented Feb 2, 2018 at 10:43
  • Right click the feature file , run special tool
    – Amias
    Commented Feb 2, 2018 at 11:07
  • That worked with generating the file. Thanks. However, I am writing the implementation in F#. So, that seems to have been the cause of the error. Many Thanks!
    – OA345
    Commented Feb 2, 2018 at 15:58
  • Specflow doesn't work with f# afaict
    – Amias
    Commented Feb 2, 2018 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.