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
Try running vstest.console.exe
with --diag:diag.txt
and inspect the output. For me it was DLL load failures for test adapters from my working directory:
TpTrace Information: 0 : 14976, 1, 2020/03/10, 15:34:22.120, 57158093583, vstest.console.exe, AssemblyResolver.OnResolve: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter: Failed to load assembly. Reason:System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Directory\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///C:\Directory\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
I worked around this by adding <loadFromRemoteSources enabled="true"/>
under <runtime>
in vstest.console.exe.config
I am having the same issue. I am using Visual Studio 2017 Community Edition.
I used these steps to successfully discover all my test cases and successfully run it:
First go to Extensions and Updates, install NUnit3 Test Adapter. If you already have, just enable it.
Restart your Visual Studio 2017, it will automatically prompt to
install your extension, if a prompt says to end task to continue
installing, just click "End Task".
After that, rebuild your Test Project and all test cases will now be identified and you can now start running your test cases.
This problem surfaces for Visual Studio 2017 again. Most likely another bug but the same outcome.
One workaround that seems to work is to uninstall Microsoft Visual Studio 2017 Remote Debugger from the affected machine.
I got this error and was able to resolve it.
I fixed this problem by reinstalling all testing related NuGet packages for the project:
Xunit
, Xunit.runner.vistualstudio
, Microsoft.Net.Test.Sdk
I faced the similar issue when tried nUnit in VS 2017 and it's not a core project.
Installing NUnit3TestAdapter
fixed the issue.