Reqnroll icon indicating copy to clipboard operation
Reqnroll copied to clipboard

Add xUnit 3 support

Open chekkan opened this issue 7 months ago • 6 comments
trafficstars

🤔 What's changed?

Adds support for xUnit 3.

⚡️ What's your motivation?

Fixes an open issue #405

🏷️ What kind of change is this?

  • :zap: New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

I've mainly concentrated on .NET 8 and C#. I think there are tests still failing for <= .NET 6. I've not tested this on .NET Framework versions and Windows. I am not confident about the changes made to support Visual Basic or FSharp.

📋 Checklist:

  • [ ] I've changed the behaviour of the code
    • [ ] I have added/updated tests to cover my changes.
  • [ ] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
  • [ ] Users should know about my change
    • [ ] I have added an entry to the "[vNext]" section of the CHANGELOG, linking to this pull request & included my GitHub handle to the release contributors list.

This text was originally taken from the template of the Cucumber project, then edited by hand. You can modify the template here.

chekkan avatar Mar 27 '25 15:03 chekkan

I see

C:\Users\runneradmin.nuget\packages\xunit.v3.core\2.0.0\buildTransitive\xunit.v3.core.targets(15,5): error : xUnit.net v3 test projects must be executable (set project property '<OutputType>Exe</OutputType>'). If this is not a test project, reference xunit.v3.extensibilty.core instead. [C:\Users\runneradmin\AppData\Local\Temp\RR\Rfc50a343\S642e957a\DefaultTestProject\DefaultTestProject.csproj], but found False.

in https://github.com/reqnroll/Reqnroll/actions/runs/14112217252?pr=538

So I think we need a separate test project voor xUnit3?

304NotModified avatar Apr 04 '25 21:04 304NotModified

@304NotModified I took a different approach by changing the project type to an executable rather than a library. I hope that's acceptable.

chekkan avatar Apr 09 '25 09:04 chekkan

@chekkan Do you have any idea why the CI was not run for this?

gasparnagy avatar Apr 29 '25 15:04 gasparnagy

@chekkan Do you have any idea why the CI was not run for this?

I had assumed it was because I didn't have the necessary permissions. But, perhaps it's because the PR was in draft mode when I pushed that change and didn't trigger the CI build.

Edit: @gasparnagy its because this PR is awaiting workflow approval from one of the maintainer. See https://github.com/reqnroll/Reqnroll/actions/runs/14793285242

chekkan avatar Apr 29 '25 18:04 chekkan

Do we have "preview" or "beta" packages for something like this? So people like me can give it a test run?

kaylumah avatar Apr 30 '25 09:04 kaylumah

Do we have "preview" or "beta" packages for something like this? So people like me can give it a test run?

Each build (github action) contains an artifact with the nuget packages. You can grab these and use them.

The latest run is here: https://github.com/reqnroll/Reqnroll/actions/runs/14793285242 Last package artifact: packages-v2.4.2-ci20250501-1011

obligaron avatar May 02 '25 12:05 obligaron

So sorry, did not get around to this. I am available to do some testing (pun intended) if its still needed Update: <PackageVersion Include="Reqnroll.xUnit.v3" Version="2.4.2-ci20250527-1136" /> worked without issue on the project

kaylumah avatar May 30 '25 07:05 kaylumah

And please also update the CHANGELOG.md file

gasparnagy avatar Jun 11 '25 15:06 gasparnagy

How far out are we from getting this merged / shipped?

kaylumah avatar Jun 21 '25 08:06 kaylumah

How far out are we from getting this merged / shipped?

Merge: I think if the open review comments are resolved, we are good to go. Release: This depends on #233

gasparnagy avatar Jun 22 '25 12:06 gasparnagy

Great news, hope to take advantage of this soon :) IMO might be worth releasing this as a beta package, if it takes some time for 233 to be done

kaylumah avatar Jul 03 '25 04:07 kaylumah

IMO might be worth releasing this as a beta package, if it takes some time for 233 to be done

Releasing a beta would cause quite some troubles because we have interface breaking changes, so other plugins would not work, etc. Each CI build produces a set of nuget packages that can be used as a "beta", I would recommend using those temporarily.

gasparnagy avatar Jul 09 '25 09:07 gasparnagy

FYI #233 had been merged :)

304NotModified avatar Jul 28 '25 21:07 304NotModified

FYI #233 had been merged :)

Could anyone help with fixing the open issues?

gasparnagy avatar Jul 29 '25 13:07 gasparnagy

@gasparnagy what are the open issues? The unresolved discussions in this PR? Or do you mean other issues besides this PR?

304NotModified avatar Jul 29 '25 14:07 304NotModified

@gasparnagy what are the open issues? The unresolved discussions in this PR? Or do you mean other issues besides this PR?

Sorry. I meant the unresolved review comments here in the PR.

gasparnagy avatar Jul 29 '25 16:07 gasparnagy

And please also update the CHANGELOG.md file

done

304NotModified avatar Aug 04 '25 21:08 304NotModified

@gasparnagy I've resolved some discussions. Please note, I haven't checked this PR in-depth myself.

I also added some docs (Copilot generated) and it looks correct to me. Not sure if it's enough, but at least it's a good start.

304NotModified avatar Aug 04 '25 22:08 304NotModified

@kaylumah could you please test with Reqnroll.xunit.v3.3.0.0-ci20250804-1446.nupkg

Artifact packages-v3.0.0-ci20250804-1446 Artifact download URL: https://github.com/reqnroll/Reqnroll/actions/runs/16735781647/artifacts/3686120693

304NotModified avatar Aug 04 '25 23:08 304NotModified

Just tried the debug package, and it works as expected. Tests pass, debugging works, rider plugin allows go to step etc.

Due note, its a small project, so there might some edgecases I dont cover in that project. Overall, I'd say release it into the wild, and we can improve on it as needed :)

kaylumah avatar Aug 05 '25 05:08 kaylumah

@kaylumah could you please test if @ignore also works? (see https://docs.reqnroll.net/latest/execution/test-results.html#ignored-tests)

I will also try to find time to try the xunit v3 package this week

304NotModified avatar Aug 05 '25 07:08 304NotModified

Done

image

Love this comment from the docs btw :) image

Its not a new feature of xunit though right?

kaylumah avatar Aug 05 '25 08:08 kaylumah

I'm working on the build fail (caused by https://github.com/reqnroll/Reqnroll/pull/706)

update: fixed

304NotModified avatar Aug 06 '25 17:08 304NotModified

FYI, fixed the conflict in the changelog, but not actively working on this PR

304NotModified avatar Aug 07 '25 13:08 304NotModified

The build is broken, not sure if I did that or that's a result of another PR

Reqnroll.xUnit.ReqnrollPlugin -> /home/runner/work/Reqnroll/Reqnroll/Plugins/Reqnroll.xUnit.ReqnrollPlugin/bin/Debug/netstandard2.0/Reqnroll.xUnit.ReqnrollPlugin.dll /home/runner/work/Reqnroll/Reqnroll/Plugins/Reqnroll.xUnit3.ReqnrollPlugin/XUnit3RuntimeProvider.cs(8,38): error CS0535: 'XUnit3RuntimeProvider' does not implement interface member 'IUnitTestRuntimeProvider.DetectExecutionStatus(Exception)' [/home/runner/work/Reqnroll/Reqnroll/Plugins/Reqnroll.xUnit3.ReqnrollPlugin/Reqnroll.xUnit3.ReqnrollPlugin.csproj]

update: seems the result of https://github.com/reqnroll/Reqnroll/pull/732

304NotModified avatar Aug 10 '25 13:08 304NotModified

The build is broken, not sure if I did that or that's a result of another PR

Reqnroll.xUnit.ReqnrollPlugin -> /home/runner/work/Reqnroll/Reqnroll/Plugins/Reqnroll.xUnit.ReqnrollPlugin/bin/Debug/netstandard2.0/Reqnroll.xUnit.ReqnrollPlugin.dll /home/runner/work/Reqnroll/Reqnroll/Plugins/Reqnroll.xUnit3.ReqnrollPlugin/XUnit3RuntimeProvider.cs(8,38): error CS0535: 'XUnit3RuntimeProvider' does not implement interface member 'IUnitTestRuntimeProvider.DetectExecutionStatus(Exception)' [/home/runner/work/Reqnroll/Reqnroll/Plugins/Reqnroll.xUnit3.ReqnrollPlugin/Reqnroll.xUnit3.ReqnrollPlugin.csproj]

update: seems the result of #732

You can just implement with returning null for now.

gasparnagy avatar Aug 10 '25 15:08 gasparnagy

You can just implement with returning null for now.

I think I could use the implementation of xUnit 2 also, as the SkipException is also there in xUnit 3 and with the mesage:

image

304NotModified avatar Aug 10 '25 21:08 304NotModified

@chekkan could you help us in getting the last things resolved? See open PR comments

304NotModified avatar Aug 15 '25 23:08 304NotModified

I guess this will be 3.1? As bug fixes has more prio then this one?

Update, it see it was the plan for 3.x already, see https://reqnroll.net/news/2025/06/roadmap-update-html-report/

304NotModified avatar Aug 23 '25 20:08 304NotModified

Class level test categories are being incorrectly attached to the FixtureData rather than then test class.

I think this just needs to change in XUnit3TestGeneratorProvider from SetProperty(_currentFixtureDataTypeDeclaration, CATEGORY_PROPERTY_NAME, category); to SetProperty(generationContext.TestClass, CATEGORY_PROPERTY_NAME, category);

Also note that the ability to set traits on individual Scenarios is not implemented yet. I think we can borrow directly from the Xunit v2 plugin for this:

public void SetTestMethodCategories(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, IEnumerable<string> scenarioCategories)
{
    foreach (string str in scenarioCategories)
    {
        SetProperty(testMethod, CATEGORY_PROPERTY_NAME, str);
    }
}

EamonHetherton avatar Aug 25 '25 05:08 EamonHetherton