Search code examples
c#excelnunitspecflow

Can't use Excel datasource in specflow, it is not working


My specflow with excel not working .I used the code like below:

Feature: Calculator
![Calculator](https://specflow.org/wp-content/uploads/2020/09/calculator.png)
Simple calculator for adding **two** numbers

Link to a feature: [Calculator](SpecFlowCalculator/Features/Calculator.feature)
***Further read***: **[Learn more about how to generate Living Documentation](https://docs.specflow.org/projects/specflow-livingdoc/en/latest/LivingDocGenerator/Generating-Documentation.html)**
@DataSource:CalculatorExamples.xlsx @DataSet:Sheet1
Scenario Outline: Add two numbers
    Given I have entered <a> into the calculator 
    And I have entered <b> into the calculator 
    When I press add
    Then the result should be <result> on the screen 


Examples:
    | a | b | result |
    | 1 | 2 | 3      |

I have definiation file like this

 [Given(@"I have entered <a> into the calculator")]
        public void GivenIHaveEnteredAIntoTheCalculator(String p0)
        {
            Console.WriteLine(p0);
            num1 = int.Parse(p0);
        }
        [Given(@"I have entered <b> into the calculator")]
        public void GivenIHaveEnteredBIntoTheCalculator(String p1)
        {
            Console.WriteLine(p1);
            num2 = int.Parse(p1);
        }

Error : And I have entered 2 into the calculator

-> No matching step definition found for the step. Use the following code to create one: [Given(@"I have entered (.*) into the calculator")] public void GivenIHaveEnteredIntoTheCalculator(int p0) { _scenarioContext.Pending(); }

I kept Excel in the same location but it is not working. I am using 3.9 specflow and 1.7 specflow plus Excel Nuget.

How can I solve this?


Solution

  • As far i see they stopped support for this feature refer this link https://github.com/SpecFlowOSS/SpecFlow/issues/1880