Search code examples
nunitxunitvisual-studio-2022

XUnit, NUnit, MSUnit all run all tests twice VS2022


In Visual Studio 2022 the test runner for XUnit, NUnit and MSUnit all run the tests twice (I switch the project between the three).

For XUnit (the last one I landed on and plan on staying with) I have the following nuget packages installed: xunit (2.4.1) and xunit.runner.visualstudio (2.4.3)

I have no relevant VS extensions installed (that I can tell... nothing with XUnit, NUnit, or MSUnit in the name).

My project file is nice and simple:

  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>

    <IsPackable>false</IsPackable>

    <PlatformTarget>x86</PlatformTarget>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AForge.Video" Version="2.2.5" />
    <PackageReference Include="AForge.Video.FFMPEG" Version="2.2.5.1-rc" />
    <PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
    <PackageReference Include="Selenium.WebDriver" Version="4.1.0" />
    <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="96.0.4664.4500" />
    <PackageReference Include="System.Drawing.Common" Version="6.0.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <None Update="avcodec-53.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="avdevice-53.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="avfilter-2.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="avformat-53.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="avutil-51.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="postproc-52.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="swresample-0.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="swscale-2.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

I'm at a loss. Any help appreciated!!

I'm at a loss.


Solution

  • I just had the same problem. I also noticed that having Fine Code Coverage enabled causes every test to be run in the background even if you only choose a single test in the Test Explorer.

    What seems to work is to enable RunMsCodeCoverage in the Fine Code Coverage settings.