Skip to content

Fix multiple public constructors for xUnit v3 compatibility#111

Merged
renemadsen merged 3 commits intomasterfrom
copilot/fix-test-class-constructors
Nov 16, 2025
Merged

Fix multiple public constructors for xUnit v3 compatibility#111
renemadsen merged 3 commits intomasterfrom
copilot/fix-test-class-constructors

Conversation

Copy link

Copilot AI commented Nov 16, 2025

xUnit v3 (used in .NET 10) enforces single public constructor per test class. Four classes violated this constraint, causing test discovery to fail.

Changes

  • TestMySqlRetryingExecutionStrategy: Made 3 unused constructors internal, keeping only ExecutionStrategyDependencies constructor public
  • MySqlConditionalFactTestCase/TheoryTestCase: Added [EditorBrowsable(EditorBrowsableState.Never)] to obsolete parameterless constructors (required for xUnit serialization but should be hidden from discovery)
  • EntitySplittingQueryMySqlTest: Made ITestOutputHelper convenience constructor internal, keeping primary constructor with fixture public

Example

Before:

public class TestMySqlRetryingExecutionStrategy : MySqlRetryingExecutionStrategy
{
    public TestMySqlRetryingExecutionStrategy() { ... }
    public TestMySqlRetryingExecutionStrategy(DbContext context) { ... }
    public TestMySqlRetryingExecutionStrategy(DbContext context, TimeSpan maxDelay) { ... }
    public TestMySqlRetryingExecutionStrategy(ExecutionStrategyDependencies dependencies) { ... }
}

After:

public class TestMySqlRetryingExecutionStrategy : MySqlRetryingExecutionStrategy
{
    internal TestMySqlRetryingExecutionStrategy() { ... }
    internal TestMySqlRetryingExecutionStrategy(DbContext context) { ... }
    internal TestMySqlRetryingExecutionStrategy(DbContext context, TimeSpan maxDelay) { ... }
    public TestMySqlRetryingExecutionStrategy(ExecutionStrategyDependencies dependencies) { ... }
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix Error: A test class may only define a single public constructor.</issue_title>
<issue_description>Doing running Functional tests, we have this error, so find and fix all those places where that is the case:

t test/EFCore.MySql.FunctionalTests -c Debug --no-build --logger "GitHubActions;report-warnings=false" --verbosity detailed

Remember that is .net core 10</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 16, 2025 18:29
- Made 3 unused constructors in TestMySqlRetryingExecutionStrategy internal
- Added EditorBrowsable(Never) attribute to xUnit test case deserialization constructors
- This resolves xUnit v3 requirement that test classes have only one public constructor

Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Made the convenience constructor internal to comply with xUnit requirement

Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error with multiple public constructors in test classes Fix multiple public constructors for xUnit v3 compatibility Nov 16, 2025
Copilot AI requested a review from renemadsen November 16, 2025 18:42
@renemadsen renemadsen marked this pull request as ready for review November 16, 2025 19:00
@renemadsen renemadsen merged commit 581acd2 into master Nov 16, 2025
1 of 55 checks passed
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.

Fix Error: A test class may only define a single public constructor.

2 participants