SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.25k stars 754 forks source link

Generate step definitions ignores step #1752

Open aliensqueegee opened 5 years ago

aliensqueegee commented 5 years ago

SpecFlow Version:

Used Test Runner

Version number: 2.4.1

Project Format of the SpecFlow project

.feature.cs files are generated using

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

<SpecFlow> Section in app.config or content of specflow.json

{
  "bindingCulture": {
    "language": "en-us"
  },
  "language": {
    "feature": "en-us"
  },
  "trace": {
    "stepDefinitionSkeletonStyle": "MethodNameUnderscores"
  },
  "plugins": []
}

Repro Project

Issue Description

I have two feature files in my test project.

The issue is that everything after 'test' string is ignored when generating step definitions. You get the message All steps are bound! when you try to generate step definitions. In the second feature file I notice that text that will be ignored is italic and gray. It's like it's considering text that will be ignored to be part of the parameter 'test'

Steps to Reproduce

Step 1:

@Calculator Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen and message 'test'

- Generate Step Definitions 
``` csharp
using System;
using TechTalk.SpecFlow;

namespace SpecFlowTests
{
    [Binding]
    public class CalculatorSteps
    {
        [Given]
        public void Given_I_have_entered_P0_into_the_calculator(int p0)
        {
            ScenarioContext.Current.Pending();
        }

        [When]
        public void When_I_press_add()
        {
            ScenarioContext.Current.Pending();
        }

        [Then]
        public void Then_the_result_should_be_P0_on_the_screen_and_message_P1(int p0, string p1)
        {
            ScenarioContext.Current.Pending();
        }
    }
}

Step 2:

@CalculatorV2 Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen and message 'test' text that will be ignored

- Generate Step Definitions returns **All steps are bound!**
``` csharp
SabotageAndi commented 5 years ago

Could you post also the generated bindings please?

aliensqueegee commented 5 years ago

@SabotageAndi I've updated issue description

SabotageAndi commented 5 years ago

Ah, you are using the method names to do the binding. Some stuff doesn't work with them. I would suggest to switch back to the definition via regular expressions.

aliensqueegee commented 5 years ago

@SabotageAndi it's working fine with regular expression definition style for this PoC project. Changing a whole project from one method name style to regular expresion might be a little to much for me right now. Any chance that this bug will be fixed for method name definition style in the near future?

SabotageAndi commented 5 years ago

If not somebody sends a PR with a fix, I don't think this will fixed soon. Currently we (as in SpecFlow Team) don't have any work planned around method name definition. It's a rarely used feature and we are only a small team with limited time and resources. Sorry.