Skip to content

All steps undefined when using .NET ReqnrollΒ #308

@jack5github

Description

@jack5github

πŸ‘“ What did you see?

All steps in feature files report as undefined.

βœ… What did you expect to see?

Feature files should have defined steps.

πŸ“¦ Which tool/library version are you using?

dotnet --version: 10.0.201
Reqnroll.MsTest: 3.3.3

πŸ”¬ How could we reproduce it?

.vscode/settings.json:

{
  "cucumber.features": ["./features/**/*.feature"],
  "cucumber.glue": ["./Steps/**/*.cs"]
}

[PROJECT NAME].csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="FluentAssertions" Version="6.12.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
    <PackageReference Include="MSTest" Version="4.1.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="4.1.0" />
    <PackageReference Include="MSTest.TestFramework" Version="4.1.0" />
    <PackageReference Include="Reqnroll.MsTest" Version="3.3.3" />
  </ItemGroup>
</Project>

features/Calculator.feature:

Feature: Calculator

  Scenario: Add two numbers
    Given The first number is 50
    And The second number is 70
    When The two numbers are added
    Then The result should be 120

Steps/Calculator.cs:

namespace [PROJECT NAME].Steps;

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Reqnroll;

[Binding]
public sealed class Calculator(FeatureContext _context)
{
    private FeatureContext context = _context;

    [Given("The first number is {int}")]
    public void SetFirst(int number)
    {
        context.Add("first", number);
    }

    [Given("The second number is {int}")]
    public void SetSecond(int number)
    {
        context.Add("second", number);
    }

    [When("The two numbers are added")]
    public void AddForResult()
    {
        context.Add("result", context.Get<int>("first") + context.Get<int>("second"));
    }

    [Then("The result should be {int}")]
    public void AssertResultEquals(int result)
    {
        Assert.AreEqual(context.Get<int>("result"), result);
    }
}

πŸ“š Any additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions