Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step Definition is not working #149

Open
HingminSon7 opened this issue Nov 29, 2023 · 8 comments
Open

Step Definition is not working #149

HingminSon7 opened this issue Nov 29, 2023 · 8 comments

Comments

@HingminSon7
Copy link

Used Visual Studio

Visual Studio 2022

Are the latest Visual Studio updates installed?

Yes

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

No response

Issue Description

Screenshot 2023-11-29 223418

image

Steps to Reproduce

  1. Create a Unit Test Project
  2. Create a feature folder and add the specflow feature file
  3. Write the gherkin scenario for the created feature file
  4. Install following packages (Spec Flow, Spec Flow.NUnit, Spec Flow.Tools.MsBuild.Generation (3.9.74) and the related packages.
  5. Right Click the script and click Define Steps
  6. Return an error and mentioned that All Steps has been defined in the file already

Link to Repository Project

No response

@marcel-tatasteel
Copy link
Contributor

@HingminSon7 .Net 8? Please use new version https://github.com/SpecFlowOSS/SpecFlow.VS/releases/tag/v2022.1.93-net8

@HingminSon7
Copy link
Author

@marcel-tatasteel Thanks for your recommendation. Unfortunately, it still not working

@HingminSon7
Copy link
Author

image

I have already using .Net8 but still the same

@kant2002
Copy link

Latest release did help me.

@divyadvs
Copy link

divyadvs commented Jan 4, 2024

Latest release did help me.

can you please confirm which release helped you to resolve the issue., because am still facing the same error for below combination
Visual studio-2022
.Net version-8 [installed the new specflow version also [v2022.1.91]
Specflow version-3.9.74
MSTest

@markovcd
Copy link

markovcd commented Jan 9, 2024

I have the same issue with said configuration (Visual studio-2022
.Net version-8 [installed the new specflow version also [v2022.1.91]
Specflow version-3.9.74
MSTest)
Works fine on rider.

This is really a blocker that prevents my team from using BDD.

@marcel-tatasteel
Copy link
Contributor

marcel-tatasteel commented Jan 9, 2024

@markovcd and @divyadvs
Just tested, and did not have issues.

What I did:

  • Install specflow extension from link above (.net 8 version)
  • Create new MsTest project
  • Reference Specflow + Specflow.MsTest
  • Add Feature file
  • Add binding file (for steps)

image

Binding file:

using TechTalk.SpecFlow;

namespace TestProject1
{
    [Binding]
    public sealed class Feature1Steps
    {
        private static int _firstNumber = 0;
        private static int _secondNumber = 0;
        private static int _result = 0;

        [Given(@"the first number is (.*)")]
        public void GivenTheFirstNumberIs(int p0)
        {
            _firstNumber = p0;
        }

        [Given(@"the second number is (.*)")]
        public void WhenTheSecondNumberIs(int p0)
        {
           _secondNumber = p0;
        }

        [When(@"when the numbers are added")]
        public void WhenWhenTheNumbersAreAdded()
        {
            _result = _firstNumber + _secondNumber;
        }

        [Then(@"the result should be (.*)")]
        public void ThenTheResultShouldBe(int p0)
        {
            Assert.AreEqual(p0, _result);
        }


    }
}

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
    <PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
    <PackageReference Include="coverlet.collector" Version="6.0.0" />
    <PackageReference Include="SpecFlow" Version="3.9.74" />
    <PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />    
  </ItemGroup>

</Project>

@Ian-Co
Copy link

Ian-Co commented Jan 10, 2024

I've been monitoring the .Net 8 changes and have successfully got the updated extension installed and working from the GitHub release linked above. I'm putting together instructions for the rest of my team and it would be my preference to install from the marketplace. Is this something that's likely to be updated soon? or is there something blocking this step?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants