Add support for xUnit v3 (feat #554)#654
Conversation
- Added `TargetFramework` as `netstandard2.0` in `Allure.Build.Tasks.csproj`. - Replaced `Path.GetRelativePath` with a custom method for better path handling. - Refactored metadata handling in `AllureV3MessageHandler.cs` using reflection. - Introduced `AllureApiAttribute` and `AllureIdAttribute` support for test results. - Added `--project` argument to `AllureSampleRunner`. - Created a new test project targeting `net8.0` with a sample test class. - Updated `GeneratedFileSource.cs` for improved stream handling.
Refactored `OnTestStarting` to handle `null` test methods by introducing `CreateFallbackTestResult`. Simplified test selection logic and adjusted handling of static test methods. Updated `OnTestPassed` to dynamically resolve `null` test methods and added null checks for default suites. Added null check for `testData.TestResult` in `EnsureTestStarted`. Introduced overloaded `ResolveTestMethod` methods for better reuse and flexibility. Added `CreateFallbackTestResult` for default `TestResult` generation. Enhanced `ResolveTestClass` to retrieve test class types from assemblies.
Added AllureRuntimeScope to manage runtime API calls within a defined scope, ensuring proper context handling and disposal. Updated AllureMessageSink to use ConcurrentDictionary for context management and added methods for handling active test unique IDs. Refactored test cases to wrap Allure API calls in AllureRuntimeScope. Enhanced README to document the new runtime scope requirement. Improved cleanup of contexts and updated examples for xUnit v3 compliance.
Updated xUnit v3 migration guidelines in `copilot-instructions.md` and added support notes in `README.md`. Enhanced `AllureRunnerReporter.cs` description for clarity. Introduced `ActivateContextForDispose` in `AllureRuntimeScope.cs` for explicit context activation during late lifecycle phases. Refactored `AllureV3MessageHandler.cs` to streamline context handling and remove redundant logging. Revised `AddDescriptionFromDisposeHtmlFromTest.cs` to use explicit context activation in `Dispose`.
Updated `test.yml` to include `Allure.Xunit.v3.Tests` in the test execution process. Added necessary `dotnet run` commands to ensure the project is tested alongside existing projects.
…f/allure-csharp into feature/xunit-v3
Changed the .NET SDK version in global.json from 10.0.203 to 10.0.201 to ensure compatibility or stability. Retained the rollForward policy as "latestFeature".
Updated the `Test2` method to use `TestContext.Current.CancellationToken` in the `Task.Delay` call. This ensures the test respects cancellation requests, enhancing responsiveness and aligning with best practices for asynchronous operations.
…DisposeHtmlFromTest v3 sample Replace ActivateContextForDispose() + bare SetDescription() with a using(AllureRuntimeScope.Begin()) scope block, consistent with the AddDescriptionFromTestHtmlFromDispose counterpart. This ensures the Allure context is properly restored and saved back after the Dispose() call so that CheckDescriptionHtmlAndDescriptionCanBeAdded passes.
Mirrors the GitHub Actions test.yml pipeline steps locally: - Clears stale Windows-path project.assets.json via find -delete (rm -rf fails on WSL2/NTFS with locked files) - Passes -p:UseSharedCompilation=false to all build steps to prevent Roslyn compiler server crash (OpenSSL 3.x invalid digest on Linux) - Restore, build, pack, build/run test samples, run all test projects
…xpected value equals value1+value2 (#xunit-v3)
…roll integration tests
|
Hello, @grootstebozewolf. Thank you for your contribution. While I appreciate the time and effort you've put into this PR, unfortunately, I have to close it. An adapter for Xunit.v3 is already in progress by our team and is expected to be completed soon. It's my fault I haven't communicated it clearly in the original issue - sorry for that. Additionally, I believe we should target MTP first. Framework-specific reporters should be an extra thing on top of it, whereas in this PR, the Xunit runner reporter is the only option. With all that in mind, I'm closing the PR. If you wish to contribute to the project, feel free to pick another issue. I recommend discussing your implementation plans in the issue first to avoid unnecessary work and to keep PRs small: smaller PRs are reviewed much faster, while long ones, like this one, often take days or even more. |
|
Thanks for the update. Happy to hear v3 support is coming. Would you be open to sharing the rough approach (MTP-first vs runner reporter) or the tracking issue so I can avoid duplicating effort? |
Context
Allure.Xunitpackage only supports xUnit v2.dotnet testworkflows.xunitpackage towardxunit.v3.Checklist