Skip to content

Conversation

@benjiro
Copy link
Member

@benjiro benjiro commented Dec 31, 2025

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.

  • Upgrades xUnit to v3
  • Upgrades Microsoft.Testing.Platform to v2
  • Updates all test projects to use the new testing framework versions
  • Refactors test assertions and lifecycle management to be compatible with xUnit v3 APIs
  • Updates Directory.Packages.props with new package versions
  • Adds global.json configuration

Related Issues

Fixes #624
Fixes #648

Notes

This is a significant infrastructure upgrade that affects all test projects:

  • OpenFeature.E2ETests
  • OpenFeature.Hosting.Tests
  • OpenFeature.IntegrationTests
  • OpenFeature.Providers.MultiProvider.Tests
  • OpenFeature.Tests

The 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

  1. Clone the repository
  2. Run dotnet test to execute the full test suite
  3. Verify all tests pass with the new xUnit v3 and mtp v2 framework
  4. Check that test output and reporting work as expected

@benjiro benjiro requested a review from a team as a code owner December 31, 2025 00:37
@benjiro benjiro marked this pull request as draft December 31, 2025 00:38
@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • Testing Framework Upgrade: The test infrastructure has been upgraded to xUnit v3 and Microsoft.Testing.Platform (mtp) v2, modernizing the entire testing framework across all test projects.
  • Package Version Updates: Key testing-related package versions have been updated in Directory.Packages.props, including Reqnroll.xunit.v3, xunit.v3.mtp-v2, and xunit.runner.visualstudio.
  • Test Project Configuration: All test projects (.csproj files) now include <OutputType>Exe</OutputType> and reference the new xUnit v3 packages. A global.json entry has been added to configure Microsoft.Testing.Platform as the test runner.
  • Asynchronous API Refactoring: Numerous asynchronous methods across test files, including provider initialization, shutdown, flag resolution, and hook executions, have been updated to explicitly accept and utilize CancellationToken parameters, aligning with modern async patterns and xUnit v3's TestContext.Current.CancellationToken.
  • Test Assertion and Lifecycle Changes: Specific test assertion patterns have been refactored, such as changing Skip.If to Assert.SkipWhen. Additionally, IAsyncLifetime methods (InitializeAsync, DisposeAsync) in test fixtures now return ValueTask instead of Task for improved performance.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +121 to +124
#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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change testing framework to Microsoft Testing Platform (MTP) Upgrade to xUnit v3

2 participants