xunit / visualstudio.xunit

VSTest runner for xUnit.net (for Visual Studio Test Explorer and dotnet test)
https://xunit.net/
Other
147 stars 80 forks source link

Dotnet test throwing System.IO.FileLoadException #122

Closed Frankwayne closed 1 year ago

Frankwayne commented 5 years ago

I have attempted to used the following xunit.runner.visualstudio

2.3.0, 2.3.1, 2.4.0 2.4.1

When using 2.2.0 my issue goes away and appears to run the unit test correctly.

All unit test run fine inside visual studio Test Explorer, the following dotnet command has the following results

dotnet test {{proejct path}} -l trx -r {{results folder path}} --filter Category!=Integration /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura

My netcoreapp2.0 unit test run just fine but the unit tests running in NETFramework, Version=v4.6.1 causes the following error,

Catastrophic failure: System.IO.FileLoadException: Could not load file or assembly 'xunit.runner.utility.net452, Version=2.3.1.3858,

I have a unit test project that is targeting the following frameworks

 <PropertyGroup>
    <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
  </PropertyGroup>

Here is a copy of my directory.Build.props that actually works. I'm not sure why kicking my xunit.runner.visualstudio version above 2.2.0 breaks my dotnet test command.

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.2" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.analyzers" Version="0.10.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />

    <PackageReference Include="coverlet.msbuild" Version="2.5.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>

    <Content Condition="$(Configuration)=='Debug'" Include="$(MsBuildThisFileDirectory)\xunit.runner.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
</Project>
Frankwayne commented 5 years ago

I have a repo of the issue at hand at

https://github.com/Frankwayne/XunitDotNetException

bradwilson commented 5 years ago

This issue belongs in https://github.com/xunit/visualstudio.xunit

htimmer commented 5 years ago

Any updates on this issue? I run into the same error. My unit test project is targeting NETFramework, Version=v4.6.2. Locally using the VS Test Explorer my test are all ok, but using the dotnet.exe test command either locally or in Azure DevOps gives the mentioned Catastrophic failure

bradwilson commented 1 year ago

Sorry for the delay in getting to this issue.

I have upgraded as much as I could in the repro, and I'm now unable to repro the problem, so I assume it's been solved by now. Please open a new issue with a modern repro if you're still experiencing any problems.