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

xunit code generator plugin generates coe that can't be compiled #2742

Open
jvmlet opened this issue Mar 10, 2024 · 0 comments
Open

xunit code generator plugin generates coe that can't be compiled #2742

jvmlet opened this issue Mar 10, 2024 · 0 comments
Labels

Comments

@jvmlet
Copy link

jvmlet commented Mar 10, 2024

SpecFlow Version

4.0.31-beta

Which test runner are you using?

xUnit

Test Runner Version Number

2.5.0

.NET Implementation

.NET 6.0

Project Format of the SpecFlow project

Sdk-style project format

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

Visual Studio Test Explorer

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

No response

Issue Description

The plugin generates the references to xunit classes in FQN style , like Xunit.Abstractions.ITestOutputHelper , Xunit.IAsyncLifetime ,ect
Consider the project with RootNamespace defined as X.Y.Z and there are classes under X.Y.Z.Xunit namespace.
What happens during compilation of generated code

   public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
        {
            testRunner.OnScenarioInitialize(scenarioInfo);
            testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs<Xunit.Abstractions.ITestOutputHelper>(_testOutputHelper);
        }

is

MyFeature.feature(53,49): Error CS0234 : The type or namespace name 'IAsyncLifetime' does not exist in the namespace 'X.Y.Z.Xunit' (are you missing an assembly reference?)

Steps to Reproduce

  1. Create test project with root namespace My.Company referencing xunit runner.
  2. Add class under namespace My.Company.Xunit
  3. Create feature file and try to compile the project.

Link to Repro Project

No response

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

No branches or pull requests

1 participant