Reqnroll
Reqnroll copied to clipboard
Add xUnit 3 support
🤔 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.
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 I took a different approach by changing the project type to an executable rather than a library. I hope that's acceptable.
@chekkan Do you have any idea why the CI was not run for this?
@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
Do we have "preview" or "beta" packages for something like this? So people like me can give it a test run?
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
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
And please also update the CHANGELOG.md file
How far out are we from getting this merged / shipped?
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
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
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.
FYI #233 had been merged :)
FYI #233 had been merged :)
Could anyone help with fixing the open issues?
@gasparnagy what are the open issues? The unresolved discussions in this PR? Or do you mean other issues besides this PR?
@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.
And please also update the CHANGELOG.md file
done
@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.
@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
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 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
Done
Love this comment from the docs btw :)
Its not a new feature of xunit though right?
I'm working on the build fail (caused by https://github.com/reqnroll/Reqnroll/pull/706)
update: fixed
FYI, fixed the conflict in the changelog, but not actively working on this PR
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
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.
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:
@chekkan could you help us in getting the last things resolved? See open PR comments
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/
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);
}
}