migrate remaining test projects from MSTest to xUnit#1
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
Three of the four test projects in the solution were still on MSTest while
VectorSharp.Chunking.Testswas 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?
VectorSharp.Embedding.Tests,VectorSharp.Storage.Tests, andVectorSharp.Embedding.NomicEmbed.Testsfrom MSTest to xUnit.MSTestpackage forMicrosoft.NET.Test.Sdk,xunit, andxunit.runner.visualstudio, and changed the global using toXunit.[TestClass]removed,[TestMethod]→[Fact],[DataTestMethod]+[DataRow]→[Theory]+[InlineData],[TestCategory]→[Trait]).Assert.AreEqual→Assert.Equal,Assert.ThrowsExactly(Async)→Assert.Throws(Async),CollectionAssert.AreEqual→Assert.Equal, etc.).TestHelpers.AssertApproximatelyEqualhelper in the Storage and NomicEmbed test projects to preserve the absolute-delta float tolerance semantics that xUnit'sAssert.Equaldoesn't offer out of the box.Xunit.SkippableFactpackage toVectorSharp.Embedding.NomicEmbed.Testsand replacedAssert.Inconclusive(...)withSkip.IfNot(...), so tests that require the ONNX model now show as skipped rather than passing when the model is missing.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 existingAreEqual(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.Inconclusivealso required a choice between early-return (passes silently when the model is absent) andSkippableFact(properly reports as skipped). The latter was chosen so missing-model runs stay visible in test reports.Test plan