Search code examples
c#bddspecflow

SpecFlow: System.FormatException: Input string was not in a correct format


I was getting the following error when running my tests using SpecFlow:

System.FormatException: Input string was not in a correct format.

And it took me a while to work out why it was happening.


Solution

  • It ended up being because I had omitted the single quotes in one of my step definitions, for example:

    [Then(@"Something adds up to a quantity of (.*)")]
    

    when it should have been

    [Then(@"Something adds up to a quantity of '(.*)'")]
    

    Note the single quotes around (.*)