-
Notifications
You must be signed in to change notification settings - Fork 22
feat: Upgrade to xUnit v3 and mtp v2 #681
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Benjamin Evenson <[email protected]>
Summary of ChangesHello @benjiro, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers a significant infrastructure upgrade by migrating the entire test suite to xUnit v3 and Microsoft.Testing.Platform v2. This modernization effort involves updating package dependencies, adjusting project configurations, and refactoring asynchronous test logic to incorporate cancellation tokens and optimized async return types. The changes aim to enhance the robustness, maintainability, and performance of the testing framework without altering existing test coverage. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully upgrades the test infrastructure to xUnit v3 and Microsoft.Testing.Platform v2. The changes are extensive and consistently applied across all test projects, including updating package versions, project files, and test code to use new APIs and propagate cancellation tokens. This is a solid modernization of the test suite. I have a couple of suggestions to improve test correctness and maintainability.
| #pragma warning disable xUnit1051 // Possible a oversight but Api.Instance.ShutdownAsync does not accept CancellationToken parameter | ||
| await providerA.Received(1).ShutdownAsync(); | ||
| await providerB.Received(1).ShutdownAsync(); | ||
| #pragma warning restore xUnit1051 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pragma disable is incorrect and misleading. xUnit1051 is for Assert.Throws misuse, which is not the case here. The comment is also not directly related to the code being suppressed.
The actual issue, which this pragma seems intended to hide, is that await cannot be used with Received(N) in NSubstitute. The following lines will cause a compile error or analyzer warning:
await providerA.Received(1).ShutdownAsync();
await providerB.Received(1).ShutdownAsync();To correctly verify that ShutdownAsync was called exactly once, you should remove the await keyword. This is the pattern used in other tests in this repository (e.g., ProviderRepositoryTests.cs).
The corrected code should be:
providerA.Received(1).ShutdownAsync();
providerB.Received(1).ShutdownAsync();This entire block including the pragma should be replaced with the corrected code.
| while (!token.IsCancellationRequested) | ||
| { | ||
| await Task.Delay(10); // artificially delay until cancelled | ||
| await Task.Delay(10, TestContext.Current.CancellationToken); // artificially delay until cancelled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the token from the method arguments in Task.Delay would make the mock's cancellable behavior entirely dependent on the token passed to ResolveStringValueAsync. This aligns better with testing the cancellation propagation to the provider method.
await Task.Delay(10, token); // artificially delay until cancelled
This PR
This PR upgrades the test infrastructure to use xUnit v3 and Microsoft.Testing.Platform (mtp) v2, modernizing the testing framework across all test projects in the dotnet-sdk.
Related Issues
Fixes #624
Fixes #648
Notes
This is a significant infrastructure upgrade that affects all test projects:
OpenFeature.E2ETestsOpenFeature.Hosting.TestsOpenFeature.IntegrationTestsOpenFeature.Providers.MultiProvider.TestsOpenFeature.TestsThe changes include updates to test lifecycle management and assertion patterns to align with xUnit v3 conventions. Net reduction of ~40 lines of code across the test suite while maintaining all existing test coverage.
How to test
dotnet testto execute the full test suite