Skip to content

Migrate all possible xUnit tests to TUnit#834

Open
AArnott wants to merge 27 commits intomainfrom
tunitMigrations
Open

Migrate all possible xUnit tests to TUnit#834
AArnott wants to merge 27 commits intomainfrom
tunitMigrations

Conversation

@AArnott
Copy link
Copy Markdown
Owner

@AArnott AArnott commented Dec 22, 2025

Comparison Before After Change
Build time (Windows) 3:28 6:53 +3:25
Test time 1:48 1:28 -0:20
Test count 16409+76+19+19 3169+4079+1031+1031 -7213
Code coverage 75% 70% -4.62%

Blocked by:

Copilot AI review requested due to automatic review settings December 22, 2025 22:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request migrates test files from xUnit to TUnit testing framework. The migration involves updating test attributes, logging mechanisms, and test context handling across multiple test files.

Key Changes

  • Migrated test attributes from xUnit ([Fact], [Theory], [InlineData]) to TUnit ([Test], [Arguments], [MatrixDataSource])
  • Replaced ITestOutputHelper with Console.WriteLine for logging
  • Changed test context cancellation token access from TestContext.Current.CancellationToken to this.TimeoutToken

Reviewed changes

Copilot reviewed 60 out of 65 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/Nerdbank.MessagePack.Tests/StructuralEqualityComparerTests.cs Removed test methods and helper types (moved to TUnit project)
test/Nerdbank.MessagePack.Tests/Nerdbank.MessagePack.Tests.csproj Removed T4 template references, added links to TUnit test files
test/Nerdbank.MessagePack.Tests/MessagePackSerializerTestBase.cs Added TimeoutToken property and Log helper method
test/Nerdbank.MessagePack.Tests/BuiltInConverterTests.cs Migrated from ITestOutputHelper.WriteLine to Console.WriteLine
test/Nerdbank.MessagePack.TUnit/VersionSafeSerializationTests.cs Migrated test attributes and updated cancellation token references
test/Nerdbank.MessagePack.TUnit/UseComparerTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/TestConstants.cs New file with shared test constants
test/Nerdbank.MessagePack.TUnit/SurrogateTests.cs Migrated test attributes and moved OriginalType to separate file
test/Nerdbank.MessagePack.TUnit/SurrogateTests.OriginalType.cs New file with OriginalType class extracted from main test file
test/Nerdbank.MessagePack.TUnit/StructuralEqualityComparerTests.cs New TUnit version with all test methods and types
test/Nerdbank.MessagePack.TUnit/StructuralEquality.cs New file with utility methods for structural equality checking
test/Nerdbank.MessagePack.TUnit/StringInterningTests.cs Migrated test attributes and cancellation token references
test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs Migrated test attributes, logging, and cancellation tokens
test/Nerdbank.MessagePack.TUnit/StreamTests.cs Migrated test attributes and cancellation tokens
test/Nerdbank.MessagePack.TUnit/ShouldSerializeTests.cs Migrated test attributes including combinatorial data sources
test/Nerdbank.MessagePack.TUnit/SharedTestTypes.cs New file with shared test types
test/Nerdbank.MessagePack.TUnit/SerializationRejectsFunctionsTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/SerializationContextTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/SerializationCallbackTests.cs Migrated test attributes and cancellation tokens
test/Nerdbank.MessagePack.TUnit/SecurityTests.cs Migrated test attributes, logging changes from WriteLine to LogInformation
test/Nerdbank.MessagePack.TUnit/SecureKeyCollectionsTests.cs Migrated test attributes and logging to Console.WriteLine
test/Nerdbank.MessagePack.TUnit/ReferencePreservationTests.cs Migrated test attributes, added AOT-related code
test/Nerdbank.MessagePack.TUnit/RawMessagePackTests.cs Migrated test attributes and cancellation tokens
test/Nerdbank.MessagePack.TUnit/PrimitivesDerializationTests.cs Added conditional compilation and migrated test attributes
test/Nerdbank.MessagePack.TUnit/PerfOverSchemaStabilityTests.cs Migrated test attributes
test/Nerdbank.MessagePack.TUnit/OptionalConvertersTests.cs Migrated test attributes and logging
test/Nerdbank.MessagePack.TUnit/OddShapeTests.cs Migrated test attributes and logging
test/Nerdbank.MessagePack.TUnit/ObjectsAsMapTests.cs Migrated test attributes and cancellation tokens
test/Nerdbank.MessagePack.TUnit/ObjectsAsArraysTests.cs Migrated test attributes including complex argument combinations
test/Nerdbank.MessagePack.TUnit/Nerdbank.MessagePack.TUnit.csproj Updated project configuration, added T4 templates and compilation includes
test/Nerdbank.MessagePack.TUnit/NativeAOTTests.cs Removed entire test class (no longer needed)
test/Nerdbank.MessagePack.TUnit/NamingPolicyApplicationTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/MessagePackWriterTests.cs Removed constructor, migrated test attributes
test/Nerdbank.MessagePack.TUnit/MessagePackWriterExtensions.cs New file with writer extension methods
test/Nerdbank.MessagePack.TUnit/MessagePackValueTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/MessagePackStringTests.cs Made class inherit from test base, migrated test attributes
test/Nerdbank.MessagePack.TUnit/MessagePackStreamingReaderTests.cs Removed constructor parameter, migrated test attributes
test/Nerdbank.MessagePack.TUnit/MessagePackSerializerTests.cs Migrated test attributes and logging to LogInformation
test/Nerdbank.MessagePack.TUnit/MessagePackSerializerTestBase.cs Added Log helper method
test/Nerdbank.MessagePack.TUnit/MessagePackSerializationExceptionTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/MessagePackReaderTests.cs Removed constructor, migrated test attributes and logging
test/Nerdbank.MessagePack.TUnit/MessagePackReaderTests.ReadString.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/MessagePackReaderTests.ReadInt.tt T4 template migrated to [Test] and Console.WriteLine
test/Nerdbank.MessagePack.TUnit/MessagePackReaderTests.ReadInt.cs Generated file from T4 template with migrations
test/Nerdbank.MessagePack.TUnit/MessagePackNamingPolicyTests.cs Migrated from [Theory]/[InlineData] to [Test]/[Arguments]
test/Nerdbank.MessagePack.TUnit/MessagePackConverterAttributeTests.cs Migrated test attributes and cancellation tokens
test/Nerdbank.MessagePack.TUnit/MessagePackAsyncWriterTests.cs Removed unused usings, updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/MessagePackAsyncReaderTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/InternedBuffersTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/IgnoreKeyAttributesTests.cs Migrated test attributes
test/Nerdbank.MessagePack.TUnit/FragmentedPipeReader.cs New file with pipe reader implementation
test/Nerdbank.MessagePack.TUnit/ExtensionTests.cs Updated [Fact] to [Test]
test/Nerdbank.MessagePack.TUnit/DoubleAssignmentTests.cs Migrated test attributes and logging
test/Nerdbank.MessagePack.TUnit/DeserializePathTests.cs Migrated test attributes and logging
test/Nerdbank.MessagePack.TUnit/DeserializeDefaultValueTests.cs Migrated test attributes and cancellation tokens
test/Nerdbank.MessagePack.TUnit/DerivedTypeMappingTests.cs Removed constructor parameter, migrated test attributes and logging
Comments suppressed due to low confidence (16)

test/Nerdbank.MessagePack.TUnit/DeserializeDefaultValueTests.cs:128

  • Disposable 'MemoryStream' is created but not disposed.
    test/Nerdbank.MessagePack.TUnit/DeserializeDefaultValueTests.cs:138
  • Disposable 'MemoryStream' is created but not disposed.
    test/Nerdbank.MessagePack.TUnit/DoubleAssignmentTests.cs:104
  • Disposable 'MemoryStream' is created but not disposed.
    test/Nerdbank.MessagePack.TUnit/SecureKeyCollectionsTests.cs:21
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/SecureKeyCollectionsTests.cs:44
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:27
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:66
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:167
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:437
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:467
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:497
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamTests.cs:39
  • This assignment to deserialized is useless, since its value is never read.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:40
  • This assignment to current is useless, since its value is never read.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:428
  • This assignment to item is useless, since its value is never read.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:458
  • This assignment to item is useless, since its value is never read.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:488
  • This assignment to item is useless, since its value is never read.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.55%. Comparing base (005554a) to head (eb88bbc).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #834      +/-   ##
==========================================
- Coverage   75.23%   70.55%   -4.68%     
==========================================
  Files         172      172              
  Lines       12403    12403              
  Branches     2534     2534              
==========================================
- Hits         9331     8751     -580     
- Misses       2238     2802     +564     
- Partials      834      850      +16     
Flag Coverage Δ
Linux 43.51% <ø> (-30.61%) ⬇️
Windows 70.55% <ø> (-4.35%) ⬇️
macOS 43.51% <ø> (-30.41%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings December 22, 2025 23:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 60 out of 65 changed files in this pull request and generated no new comments.

@AArnott
Copy link
Copy Markdown
Owner Author

AArnott commented Dec 23, 2025

Coverage number losses appear to be at least partly due to empty .cobertura.xml files in some cases. See this discussion.

Copilot AI review requested due to automatic review settings February 7, 2026 12:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 61 out of 66 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (18)

test/Nerdbank.MessagePack.TUnit/VersionSafeSerializationTests.cs:200

  • In DeserializeMaybeAsync's async branch, the MonitoringStream wrapper is created to hide the underlying MemoryStream type, but DeserializeAsync is called with the raw MemoryStream (ms) instead of the wrapper. This defeats the stated intent and may let the library take the stream fast path; pass wrapper to DeserializeAsync to actually test the non-fast-path behavior.
    test/Nerdbank.MessagePack.TUnit/DeserializeDefaultValueTests.cs:128
  • Disposable 'MemoryStream' is created but not disposed.

This issue also appears on line 138 of the same file.
test/Nerdbank.MessagePack.TUnit/DeserializeDefaultValueTests.cs:138

  • Disposable 'MemoryStream' is created but not disposed.
    test/Nerdbank.MessagePack.TUnit/DoubleAssignmentTests.cs:104
  • Disposable 'MemoryStream' is created but not disposed.
    test/Nerdbank.MessagePack.TUnit/MessagePackSerializerTests.cs:501
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/SecureKeyCollectionsTests.cs:21
  • Redundant call to 'ToString' on a String object.

This issue also appears on line 44 of the same file.
test/Nerdbank.MessagePack.TUnit/SecureKeyCollectionsTests.cs:44

  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:27
  • Redundant call to 'ToString' on a String object.

This issue also appears in the following locations of the same file:

  • line 66
  • line 167
  • line 437
  • line 467
  • line 497
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:66
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:167
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:437
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:467
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:497
  • Redundant call to 'ToString' on a String object.
    test/Nerdbank.MessagePack.TUnit/StreamTests.cs:39
  • This assignment to deserialized is useless, since its value is never read.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:40
  • This assignment to current is useless, since its value is never read.

This issue also appears in the following locations of the same file:

  • line 428
  • line 458
  • line 488
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:428
  • This assignment to item is useless, since its value is never read.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:458
  • This assignment to item is useless, since its value is never read.
    test/Nerdbank.MessagePack.TUnit/StreamingEnumerableTests.cs:488
  • This assignment to item is useless, since its value is never read.

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.

2 participants