I am in the process of upgrading our existing solution to .Net 4.6.1 and have been unable to get our unit tests to run during a server build. Locally they run as expected an
This is a known issue for .Net 4.6 now.
Unable to run .Net 4.6.x unit tests as part of a XAML TFS Build with TFS 2015 UPdate1 Source:https://connect.microsoft.com/VisualStudio/feedback/details/2245723
Here is a similar question for you reference: Unable to run .Net 4.6 Unit tests of TFS 2015 XAML build server
I was getting a similar issue and noticed somehow an app.config
file had been added to my test project. Removing this config file fixed it for me.
I solved this issue by installing NUnit3TestAdapter NuGet into my project (https://www.nuget.org/packages/NUnit3TestAdapter/).
dotnet add package NUnit3TestAdapter --version 3.17.0
My .csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="RestSharp" Version="106.11.7" />
</ItemGroup>
</Project>
You can try to change your default processor architecture in your Test Setting from X86 to X64. In my case this was the problem.
This happens if the platform target of your project under test is set to x64
.
In Visual Studio 2017 I just uninstall and reinstall NUnitTestAdapter or install new package like NUnitTestAdapter.WithFramework package and problem gone.
In my case Reinstalling Nunit3 Adapter, Deleting temp folders, Changing architecture and nothing worked. Its because of the Daemon Resharper caused the problem.
Add or Remove Programs> Find Resharper > Repair > Install again > Restart VS
That resolves the issues.