-
-
Notifications
You must be signed in to change notification settings - Fork 27
Migrate test suite from xUnit + FluentAssertions to NUnit 4.4.0 with controlled concurrency #832
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
Conversation
Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
UnshallowCRITICAL: Perform a full, recursive unshallow. A shallow clone ( Required Tools
CRITICAL: Install all three SDKs via the official script (this can work on LINUX, do not bother checking the current versions install LATEST REGARDLESS, DO THIS FIRST, FIRST, FIRST BEFORE DOING ANYTHING ELSE) # Download the installation script
Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1
# Install .NET 8 SDK
./dotnet-install.ps1 -Channel 8.0 -InstallDir ./.dotnet
# Install .NET 9 SDK
./dotnet-install.ps1 -Channel 9.0 -InstallDir ./.dotnet
# Install .NET 10 SDK
./dotnet-install.ps1 -Channel 10.0 -InstallDir ./.dotnet(Tip: ensure 🛠️ Build & Test Commands (Windows PowerShell or CMD, repository root)CRITICAL: dotnet --info
# CRITICAL: restore workloads from /src
cd src
dotnet workload restoreThen can you add Can you add these to the root folders .editorconfig at the end of the file. Add a reference to the NUnitanalyzers package to the test projects <PackageVersion Include="NUnit.Analyzers" Version="4.10.0" />Then without modify the .editorconfig after that point can you run and compile and test for any failing nunit analyzers that meet our specifications. Done that likely will failure this setup prefers |
|
@copilot remove DiffEngine (since its a dependency on Verify.NUnit anyway, update Verify.NUnit to Verify.NUnit 31.0.1 CRITICAL CRITICAL CRITICAL, DO THIS BEFORE ANYTHING ELSE UnshallowCRITICAL: Perform a full, recursive unshallow. A shallow clone ( Required Tools
CRITICAL: Install all three SDKs via the official script (this can work on LINUX, do not bother checking the current versions install LATEST REGARDLESS, DO THIS FIRST, FIRST, FIRST BEFORE DOING ANYTHING ELSE) # Download the installation script
Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1
# Install .NET 8 SDK
./dotnet-install.ps1 -Channel 8.0 -InstallDir ./.dotnet
# Install .NET 9 SDK
./dotnet-install.ps1 -Channel 9.0 -InstallDir ./.dotnet
# Install .NET 10 SDK
./dotnet-install.ps1 -Channel 10.0 -InstallDir ./.dotnet(Tip: ensure 🛠️ Build & Test Commands (Windows PowerShell or CMD, repository root)CRITICAL: dotnet --info
# CRITICAL: restore workloads from /src
cd src
dotnet workload restore |
Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
... Done! Added NUnit.Analyzers 4.10.0 and all 108 analyzer rules to .editorconfig. Fixed all analyzer warnings including:
Build succeeds with 0 NUnit analyzer errors, all 68 tests passing. (commit 40d789e) |
Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
Done! Completed all critical steps:
All 68 tests passing on both net8.0 and net9.0. (commit 7925dfc) Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Objective@copilot Refactor the Mandatory Prerequisite Actions
Task 1: Create
|
The comment appears to be truncated at
But I need the complete file content to implement this correctly. Please share the rest of the XML structure. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
✅ Migration Complete!
Test Results:
Changes Made:
./.dotnet/srcdirectory successfullyAssert.Multiple(() => { })withusing (Assert.EnterMultipleScope()) { }.Countassertions to useHas.CountconstraintIs.EqualTo(0)withIs.Zerofor better readabilityAssert.EnterMultipleScope()blocksSee NUNIT_MIGRATION.md for detailed documentation.
Original prompt
Migrate xUnit + FluentAssertions to NUnit 4.4.0 with Controlled Concurrency
Unshallow
CRITICAL: Perform a full, recursive unshallow. A shallow clone (
--depth 1) will fail because the build reads git version info.Required Tools
CRITICAL: Install all three SDKs via the official script (this can work on LINUX, do not bother checking the current versions install LATEST REGARDLESS, DO THIS FIRST, FIRST, FIRST BEFORE DOING ANYTHING ELSE)
(Tip: ensure
./.dotnetis on PATH for this shell session, or call it explicitly via./.dotnet/dotnet.)🛠️ Build & Test Commands (Windows PowerShell or CMD, repository root)
CRITICAL:
dotnet workload restoremust be run from/srcbefore building.1. Update Test Project Packages
Remove
xunitxunit.runner.visualstudioFluentAssertionsAdd
NUnit(4.4.0)NUnit3TestAdapter(latest stable, e.g., 5.*)Microsoft.NET.Test.Sdk(latest stable, e.g., 17.*)Updated
.csprojExample:Tip: Use version ranges (e.g.,
5.*,17.*) for CI to track minor updates, or lock to specific versions after validation.2. Configure Concurrency for Static Classes
To prevent concurrency issues with ReactiveUI's static classes, run tests sequentially within each test fixture (class) but allow parallelism across fixtures.
2.1 Assembly-Level Concurrency
Add an
AssemblyInfo.Parallel.csfile (outside any namespace) in each test project:ParallelScope.Fixtures: Runs test fixtures in parallel, but tests within each fixture sequentially.LevelOfParallelism(4): Caps parallel workers (adjust based on CI resources, e.g., CPU count/2).2.2 CI Runsettings
Create a
tests.runsettingsfile at the repo root:Usage:
dotnet test --settings tests.runsettingsOverride for full serialization (if static state is fragile):
dotnet test -- NUnit.NumberOfTestWorkers=13. xUnit to NUnit Attribute & API Mappings
[Fact][Test][Theory]+[InlineData(...)][TestCase(...)][Theory]+[MemberData][TestCaseSource(nameof(Data))][Theory]+[ClassData<T>][TestCaseSource(typeof(T))]Assert.Equal(a,b)Assert.That(b, Is.EqualTo(a))Assert.NotEqual(a,b)Assert.That(b, Is.Not.EqualTo(a))Assert.True(expr)Assert.That(expr, Is.True)Assert.False(expr)Assert.That(expr, Is.False)Assert.Null(x)Assert.That(x, Is.Null)Assert.NotNull(x)Assert.That(x, Is.Not.Null)Assert.Throws<T>(...)Assert.Throws<T>(...)orAssert.That(..., Throws.TypeOf<T>())Assert.Collection/ContainsAssert.That(coll, Does.Contain(item))Trait("Category","X")[Category("X")]IClassFixture<T>[OneTimeSetUp]/[OneTimeTearDown]with shared state[Collection("name")][NonParallelizable]on conflicting fixtures4. Remove FluentAssertions: Convert to Assert.That
Common Conversions:
actual.Should().Be(expected)Assert.That(actual, Is.EqualTo(expected))actual.Should().NotBe(expected)Assert.That(actual, Is.Not.EqualTo(expected))flag.Should().BeTrue()Assert.That(flag, Is.True)value.Should().BeNull()Assert.That(value, Is.Null)💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.