SpecFlowOSS / SpecFlow.VS

The next version of the Visual Studio extension for SpecFlow
MIT License
36 stars 10 forks source link

Step Definition is not working #149

Open HingminSon7 opened 8 months ago

HingminSon7 commented 8 months ago

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 commented 7 months ago

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

HingminSon7 commented 7 months ago

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

HingminSon7 commented 7 months ago

image

I have already using .Net8 but still the same

kant2002 commented 7 months ago

Latest release did help me.

divyadvs commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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

What I did:

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 commented 6 months ago

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?