Skip to content

xUnit in VS 2026, .NET 10 #449

@vmelamed

Description

@vmelamed

I migrated a small project to .NET 10 and I am using VS 2026 Pro. However, the behavior is quite erratic:

  1. If I run the tests in a CLI with dotnet test or dotnet run -- all looks good.
  2. If I debug individual tests, again - all green.
  3. If I try to run some or all tests - the tests are skipped and in the output pane I see something like this:
    ========== Starting test run ==========
    [xUnit.net 00:00:00.01] xUnit.net VSTest Adapter v3.1.5+1b188a7b0a (64-bit .NET 10.0.0)
    [xUnit.net 00:00:00.20] Glob.Api.Tests: Catastrophic failure: System.InvalidOperationException: Test process did not return valid JSON (non-object).
       at Xunit.v3.TestProcessLauncherAdapter.GetAssemblyInfo(ITestProcessLauncher launcher, XunitProjectAssembly projectAssembly)
       at Xunit.v3.TestProcessLauncherAdapter.GetAssemblyInfo(XunitProjectAssembly projectAssembly)
       at Xunit.Runner.v3.Xunit3..ctor(XunitProjectAssembly projectAssembly, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink, ITestProcessLauncher testProcessLauncher)
       at Xunit.Runner.v3.Xunit3.ForDiscoveryAndExecution(XunitProjectAssembly projectAssembly, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink, ITestProcessLauncher testProcessLauncher)
       at Xunit.XunitFrontController.Create(XunitProjectAssembly projectAssembly, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink, ITestProcessLauncher testProcessLauncher)
       at Xunit.Runner.VisualStudio.VsTestRunner.RunTestsInAssembly(IRunContext runContext, IFrameworkHandle frameworkHandle, LoggerHelper logger, TestPlatformContext testPlatformContext, RunSettings runSettings, IMessageSink reporterMessageHandler, AssemblyRunInfo runInfo)
       at Xunit.Runner.VisualStudio.VsTestRunner.RunTestsInAssembly(IRunContext runContext, IFrameworkHandle frameworkHandle, LoggerHelper logger, TestPlatformContext testPlatformContext, RunSettings runSettings, IMessageSink reporterMessageHandler, AssemblyRunInfo runInfo)
    ========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in 217 ms ==========
    
  4. I use central package management and the relevant parts look like this:
    • Directory.Packages.props:
      <Project>
        <PropertyGroup>
          <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
          <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
        </PropertyGroup>
        <ItemGroup>
          <PackageVersion Include="System.Memory" Version="4.6.3" />
          <PackageVersion Include="System.CommandLine" Version="2.0.0" />
          <PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
          <PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
          <PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.0" />
          <PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
          <PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" />
          <PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="10.0.0" />
          <PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
          <PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="10.0.0" />
          <PackageVersion Include="Markdig" Version="0.43.0" />
          <PackageVersion Include="MinVer" Version="6.0.0" />
      
          <!-- The test stack: -->
          <!--<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.1.0" />-->
          <PackageVersion Include="FluentAssertions" Version="8.8.0" />
          <PackageVersion Include="xunit.v3" Version="3.2.0" />
      
          <!-- These should be redundant for the test platform -->
          <PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
          <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
          <!-- These should be redundant for the test platform -->
      
          <!--<PackageVersion Include="xunit.v3.extensibility.core" Version="3.1.0" />-->
          <PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
      
          <PackageVersion Include="BenchmarkDotNet" Version="0.15.4" />
          <PackageVersion Include="BenchmarkDotNet.Annotations" Version="0.15.4" />
        </ItemGroup>
      </Project>
      
    • Directory.Build.props:
      <Project>
        <PropertyGroup Label="Packages">
          <TargetFramework>net10.0</TargetFramework>
          <LangVersion>latest</LangVersion>
          <Nullable>enable</Nullable>
          <ImplicitUsings>enable</ImplicitUsings>
          <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
          ...
        </PropertyGroup>
      
        <ItemGroup>
          <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
          ...
          <PackageReference Include="MinVer">
            <PrivateAssets>all</PrivateAssets>
          </PackageReference>
        </ItemGroup>
      
        <PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectDirectory), '[/\\]test[/\\]'))">
      
          <!-- Test projects settings -->
          <OutputType>Exe</OutputType>
          <IsTestProject>true</IsTestProject>
          <IsPackable>false</IsPackable>
          <RunSettingsFilePath>$(MSBuildProjectDirectory)\..\..\test.runsettings</RunSettingsFilePath>
          <GenerateDocumentationFile>false</GenerateDocumentationFile>
          <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
          <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
          <NoWarn>            $(NoWarn);CA1031;CA1701;CA1702;CA1707;CA1806;CA2211;CS0618;CS1572;CS1573;CS1574;CS1591;CS1711;IDE0021;IDE0022;IDE0039;IDE0065;IDE1006;IDE2000;IDE2002;IDE0058;IDE0290
          </NoWarn>
        </PropertyGroup>
      
        <ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectDirectory), '[/\\]test[/\\]')) and $([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectName), '^*.Tests$'))">
          <PackageReference Include="FluentAssertions" />
          <PackageReference Include="xunit.v3" />
      
          <!-- These should be redundant for the test platform -->
          <PackageReference Include="Microsoft.NET.Test.Sdk" />
          <PackageReference Include="xunit.runner.visualstudio">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          </PackageReference>
          <!-- These should be redundant for the test platform -->
      
          <PackageReference Include="coverlet.msbuild">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          </PackageReference>
        </ItemGroup>
      
        <!-- for test utility/library projects in the ./test folder: -->
        <ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectDirectory), '[/\\]test[/\\]')) and !$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectName), '^*.Tests$'))">
          <PackageReference Include="xunit.v3.extensibility.core" />
        </ItemGroup>
      
        <!-- Common usings for test projects in the ./test folder: -->
        <ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectDirectory), '[/\\]test[/\\]'))">
          <Using Include="Xunit" />
          <Using Include="FluentAssertions" />
          <Using Include="FluentAssertions.Formatting" />
          <Using Include="FluentAssertions.Extensibility" />
        </ItemGroup>
        ...      
      </Project>
      
    • test.runsettings:
      <?xml version="1.0" encoding="utf-8"?>
      <RunSettings>
        <RunConfiguration>
          <CollectSourceInformation>true</CollectSourceInformation>
          <MaxCpuCount>0</MaxCpuCount>
          <TargetPlatform>x64</TargetPlatform>
          <TestSessionTimeout>600000</TestSessionTimeout>
        </RunConfiguration>
      
        <xUnit>
          <AppDomain>denied</AppDomain>
          <Culture>en-US</Culture>
          <DiagnosticMessages>true</DiagnosticMessages>
          <InternalDiagnostics>true</InternalDiagnostics>
          <LongRunningTestSeconds>10</LongRunningTestSeconds>
          <MaxParallelThreads>-1</MaxParallelThreads>
          <AssertEquivalentMaxDepth>50</AssertEquivalentMaxDepth>
          <MethodDisplay>classAndMethod</MethodDisplay>
          <MethodDisplayOptions>none</MethodDisplayOptions>
          <NoAutoReporters>false</NoAutoReporters>
          <ParallelAlgorithm>conservative</ParallelAlgorithm>
          <ParallelizeAssembly>true</ParallelizeAssembly>
          <ParallelizeTestCollections>true</ParallelizeTestCollections>
          <PreEnumerateTheories>true</PreEnumerateTheories>
          <PrintMaxEnumerableLength>5</PrintMaxEnumerableLength>
          <PrintMaxObjectDepth>3</PrintMaxObjectDepth>
          <PrintMaxObjectMemberCount>5</PrintMaxObjectMemberCount>
          <PrintMaxStringLength>50</PrintMaxStringLength>
          <ReporterSwitch>json</ReporterSwitch>
          <ShadowCopy>true</ShadowCopy>
          <ShowLiveOutput>true</ShowLiveOutput>
          <Explicit>off</Explicit>
          <FailSkips>false</FailSkips>
          <FailWarns>false</FailWarns>
          <StopOnFail>false</StopOnFail>
        </xUnit>
        ...
      
      
  5. Lastly. The documentation suggests that adding xunit.runner.visualstudio and Microsoft.NET.Test.Sdk would be redundant, but if I remove them the behavior gets really weird: the icon of the test project start flickering (like some UI infinite loop) and if you try to do some work in VS - it just gets grey and you have to kill the process.

Sory for the huge message (I just tried to include all relevant information) and if you have any questions please do not hesitate to ask.

I really hope that I have something improperly configured or I am doing something wrong, otherwise I would be very disappointed with VS 2026 and the Testing Platform. Like I said, looks like xUnit works from the CLI.

Thank you
Val

Metadata

Metadata

Assignees

No one assigned

    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