Skip to content

TimeOutException enabling code coverage with v2 #214

@JuanZamudioGBM

Description

@JuanZamudioGBM

Hi, I’m trying to upgrade from xUnit v2 to V3 the test that run on our CI/CD and having some problems with code coverage.

With VSTest the command that we use is something like this:
dotnet test --no-restore --no-build --configuration Release --logger "trx;LogFileName=Models.UnitTests.trx" --results-directory src/test-results --settings runsettings_models.xml --collect:"XPlat Code Coverage" src/UnitTests/Models.UnitTests/Models.UnitTests.csproj

The csproj of the test project looks something like this:

<PropertyGroup>
    <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
    <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
    <TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
  </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <AllowedReferenceRelatedFileExtensions>.pdb;.xml</AllowedReferenceRelatedFileExtensions>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
  </PropertyGroup>
…
<ItemGroup>
    <PackageReference Include="AwesomeAssertions" Version="9.4.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
    <PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.5.2" />
    <PackageReference Include="Moq" Version="4.20.72" />
    <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="xunit.v3.mtp-v2" Version="3.2.2" />
    <PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

Running the tests works ok

dotnet run --project src/UnitTests/Models.UnitTests/Models.UnitTests.csproj
xUnit.net v3 Microsoft.Testing.Platform v2 Runner v3.2.2+728c1dce01 (64-bit .NET 10.0.5)


Test run summary: Passed! - src\UnitTests\Models.UnitTests\bin\Debug\net10.0\Models.UnitTests.dll (net10.0|x64)
  total: 15
  failed: 0
  succeeded: 15
  skipped: 0
  duration: 313ms

But adding the flags for code coverage fails with a TimeoutException

dotnet run --project src/UnitTests/.Models.UnitTests/Models.UnitTests.csproj -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --diagnostic --diagnostic-synchronous-write
xUnit.net v3 Microsoft.Testing.Platform v2 Runner v3.2.2+728c1dce01 (64-bit .NET 10.0.5)

Diagnostic file (level 'Trace' with sync flush): [redacted]\Models.UnitTests\bin\Debug\net10.0\TestResults\log_260331022506479.diag
Diagnostic file (level 'Trace' with sync flush): [redacted]\Models.UnitTests\bin\Debug\net10.0\TestResults\log_260331022507230.diag

Unhandled exception. System.TimeoutException: The operation has timed out.
   at System.IO.Pipes.NamedPipeClientStream.ConnectInternal(Int32 timeout, CancellationToken cancellationToken, Int32 startTime)
   at Microsoft.CodeCoverage.Interprocess.LoggerClient.ConnectPipe()
   at Microsoft.CodeCoverage.Interprocess.LoggerClient.SendMessage(Action`1 writerAction)
   at Microsoft.CodeCoverage.Interprocess.LoggerClient.SendGenerateReportsRequestMessage()
   at Microsoft.Testing.Extensions.CodeCoverage.TestingPlatformCoverageDynamicTestSessionLifetimeHandler.OnTestSessionFinishingAsync(ITestSessionContext testSessionContext)
   at Microsoft.Testing.Platform.Hosts.CommonHost.NotifyTestSessionEndAsync(ITestSessionContext testSessionContext, BaseMessageBus baseMessageBus, ServiceProvider serviceProvider, IPlatformOpenTelemetryService otelService) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 240
   at Microsoft.Testing.Platform.Hosts.CommonHost.ExecuteRequestAsync(ProxyOutputDevice outputDevice, ITestSessionContext testSessionInfo, ServiceProvider serviceProvider, BaseMessageBus baseMessageBus, ITestFramework testFramework, ClientInfo client) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 171
   at Microsoft.Testing.Platform.Hosts.ConsoleTestHost.InternalRunAsync(CancellationToken cancellationToken) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/ConsoleTestHost.cs:line 85
   at Microsoft.Testing.Platform.Hosts.ConsoleTestHost.InternalRunAsync(CancellationToken cancellationToken) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/ConsoleTestHost.cs:line 117
   at Microsoft.Testing.Platform.Hosts.CommonHost.RunTestAppAsync(IPlatformOpenTelemetryService platformOTelService, CancellationToken testApplicationCancellationToken) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 130
   at Microsoft.Testing.Platform.Hosts.CommonHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 44
   at Microsoft.Testing.Platform.Hosts.CommonHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 83
   at Microsoft.Testing.Platform.Hosts.TestHostControlledHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostControlledHost.cs:line 24
   at Microsoft.Testing.Platform.Builder.TestApplication.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs:line 223
   at Xunit.MicrosoftTestingPlatform.TestPlatformTestFramework.RunAsync(String[] args, Action`2 extensionRegistration) in /_/src/common/MicrosoftTestingPlatform/TestPlatformTestFramework.cs:line 334
   at Models.UnitTests.AutoGenerated.XunitAutoGeneratedEntryPoint.Main(String[] args) in [redacted]Models.UnitTests\obj\Debug\net10.0\XunitAutoGeneratedEntryPoint.cs:line 13

The files end like this

[02:25:16.294 xUnit.net - Information]   Finished:    Models.UnitTests (ID = '66ccf80fed28e7a1a4974fb02f07750ee77b5fd8c4a26a8a28e26187941d6a99')
[02:25:16.304 xUnit.net - Information] === TEST EXECUTION SUMMARY ===
[02:25:16.310 xUnit.net - Information]    Models.UnitTests  Total: 15, Errors: 0, Failed: 0, Skipped: 0, Not Run: 0, Time: 8.355s
2026-03-31T02:25:16.3150593+00:00 Microsoft.Testing.Platform.Messages.AsynchronousMessageBus TRACE The producer '' (ID: TestHostTestFrameworkInvoker) pushed data:
TestRequestExecutionTimeInfo { DisplayName = TestRequestExecutionTimeInfo, Description = Information about the test execution times., TimingInfo = TimingInfo { StartTime = 03/31/2026 2:25:07 AM +00:00, EndTime = 03/31/2026 2:25:16 AM +00:00, Duration = 00:00:08.6870482 } }

[02:25:16.320 TestingPlatformCoverageDynamicTestSessionLifetimeHandler - Information] LoggerClient.SendGenerateReportsRequestMessage: Sending message
[02:25:07.770 TestingPlatformCoverageProcessMonitor - Information] CoveragePipeClient.SendEmptyModuleInstrumentedMessage[0]
[02:25:07.770 TestingPlatformCoverageProcessMonitor - Information] LoggerBase.LoadModuleData[0]: finished Path:C:\Program Files\dotnet\shared\Microsoft.NETCore.App\10.0.5\System.Collections.NonGeneric.dll, time taken: 1
[02:25:07.821 TestingPlatformCoverageProcessMonitor - Information] LoggerBase.LoadModuleData[0]: started Path:[redacted]Models.UnitTests\bin\Debug\net10.0\Models.dll
[02:25:07.822 TestingPlatformCoverageProcessMonitor - Debug] SourceRootTranslator.InternalResolveFilePath: Mapping resolved: '[redacted]Models\obj\Debug\net10.0\Models.pdb' -> '[redacted]Models\obj\Debug\net10.0\.Models.pdb'
[02:25:07.822 TestingPlatformCoverageProcessMonitor - Information] PdbRederProvider.TryFindPdbPath: OriginalLocation, Path:[redacted]Models\obj\Debug\net10.0\Models.pdb, fileExists: True
[02:25:07.841 TestingPlatformCoverageProcessMonitor - Information] MsdiaPdbReaderFactory.GetNativeDataSize for [redacted]Models\obj\Debug\net10.0\Models.pdb returned data size 2320

Any pointers in what I'm doing wrong?

Thanks a lot
Juan Zamudio

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions