SpecFlow.VS icon indicating copy to clipboard operation
SpecFlow.VS copied to clipboard

Step Definition is not working

Open HingminSon7 opened this issue 2 years ago • 8 comments

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

HingminSon7 avatar Nov 29 '23 22:11 HingminSon7

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

marcel-tatasteel avatar Dec 04 '23 12:12 marcel-tatasteel

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

HingminSon7 avatar Dec 06 '23 23:12 HingminSon7

image

I have already using .Net8 but still the same

HingminSon7 avatar Dec 07 '23 15:12 HingminSon7

Latest release did help me.

kant2002 avatar Dec 17 '23 17:12 kant2002

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

divyadvs avatar Jan 04 '24 10:01 divyadvs

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.

markovcd avatar Jan 09 '24 09:01 markovcd

@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>

marcel-tatasteel avatar Jan 09 '24 10:01 marcel-tatasteel

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?

Ian-Co avatar Jan 10 '24 15:01 Ian-Co