Skip to content

migrate remaining test projects from MSTest to xUnit#1

Merged
AdamTovatt merged 1 commit into
masterfrom
migrate-to-xunit
Apr 19, 2026
Merged

migrate remaining test projects from MSTest to xUnit#1
AdamTovatt merged 1 commit into
masterfrom
migrate-to-xunit

Conversation

@AdamTovatt
Copy link
Copy Markdown
Owner

Why?

Three of the four test projects in the solution were still on MSTest while VectorSharp.Chunking.Tests was already on xUnit. Consolidating on a single framework removes a source of inconsistency and lets every project share the same attributes, assertion style, and runner configuration.

What?

  • Converted VectorSharp.Embedding.Tests, VectorSharp.Storage.Tests, and VectorSharp.Embedding.NomicEmbed.Tests from MSTest to xUnit.
  • Swapped the MSTest package for Microsoft.NET.Test.Sdk, xunit, and xunit.runner.visualstudio, and changed the global using to Xunit.
  • Rewrote attributes ([TestClass] removed, [TestMethod][Fact], [DataTestMethod] + [DataRow][Theory] + [InlineData], [TestCategory][Trait]).
  • Rewrote assertions (Assert.AreEqualAssert.Equal, Assert.ThrowsExactly(Async)Assert.Throws(Async), CollectionAssert.AreEqualAssert.Equal, etc.).
  • Added a small TestHelpers.AssertApproximatelyEqual helper in the Storage and NomicEmbed test projects to preserve the absolute-delta float tolerance semantics that xUnit's Assert.Equal doesn't offer out of the box.
  • Added the Xunit.SkippableFact package to VectorSharp.Embedding.NomicEmbed.Tests and replaced Assert.Inconclusive(...) with Skip.IfNot(...), so tests that require the ONNX model now show as skipped rather than passing when the model is missing.
  • Disabled parallelism assembly-wide in VectorSharp.Embedding.NomicEmbed.Tests (all classes were previously [DoNotParallelize]), and deleted the MSTest [Parallelize] settings file from the other two projects since xUnit's defaults are fine there.

Challenges

xUnit's Assert.Equal(float, float, int) takes decimal places instead of an absolute delta, which didn't match the existing AreEqual(expected, actual, 0.0001f) calls. Introducing a dedicated helper kept the original tolerance semantics without sprinkling ad-hoc math across every float assertion.

Handling Assert.Inconclusive also required a choice between early-return (passes silently when the model is absent) and SkippableFact (properly reports as skipped). The latter was chosen so missing-model runs stay visible in test reports.

Test plan

  • `dotnet build` clean.
  • `dotnet test` on `VectorSharp.Embedding.Tests` — 23/23 passing.
  • `dotnet test` on `VectorSharp.Storage.Tests` (excluding the heavy perf tests) — 110/110 passing.
  • `dotnet test` on `VectorSharp.Embedding.NomicEmbed.Tests` — 2 passing, 13 properly skipped (model not present locally).
  • `dotnet test` on `VectorSharp.Chunking.Tests` — 83/83 still passing (regression check).

@AdamTovatt AdamTovatt merged commit fdcd28e into master Apr 19, 2026
1 check passed
@AdamTovatt AdamTovatt deleted the migrate-to-xunit branch April 19, 2026 17:08
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.

1 participant