Xunit Unit Tests will not run
I was having a similar issue as yours, stating could not find dependent assembly
; when in fact, that assembly was there and available to the xUnit VS runner. However, what the actual issue was, I had Visual Studio set to use the 32bit
test runner by default. The 'dependent assembly' it couldn't find was simply a different processor architecture than the xUnit test runner being used.
To fix, as mentioned here, from the Visual Studio menu, go to Test -> Test Settings -> Default Processor Architecture
and set that to X64
if you are using 64bit
assemblies, or X86
if you are using 32bit
assemblies. The error that the xUnit VS runner gives is very misleading to try to debug this issue.
This issue I saw when installing Visual Studio on a new machine. The tests would run on my desktop maching in Visual Studio, but not on my laptop.
I encountered the same issue, but I have already had Visual Studio 2017 15.5.4 installed. In order to make it work I updated all xunit
related references and now my .csproj relevant references look like this:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
Not really sure what was not working, but my advice is to make sure that these reference are within csproj and have these minimum versions.
I had the same problem and I fixed it by updating Visual Studio 2017 from 15.5.2 to 15.5.4 and updating my test project references from:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
to:
<ItemGroup>
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>
And restarting Visual Studio (apparently VS caches and uses the previous version even after you've updated).
Not sure if one of the 3 things or the combination of them fixed it.
Installing or updating "xunit.runner.visualstudio" package did the trick for me. Until that, it was not working with framework 462.