Reputation: 1411
Error : No tests found to run - while debugging/running C# Unit test cases -- Visual studio 2017 15.5.1 not discovering test cases.
Framework Microsoft.NET framework 4.6.1
Added Test adapters as below MSTest.TestAdapter.1.2.0 MSTest.TestFramework.1.2.0
Test explorer not showing the test cases.
This started happening after upgrading visual studio. Some unit test projects test cases do not get discovered in the test explorer. When try to debug or run it says "No tests found to run."
I tried deleting project and recreating it again .. but didn't worked.
Output [4/3/2018 2:59:25 PM Informational] No tests found to run.
I have updated VS to 15.6.4 Deleting VS test cache files DEL %TEMP%\VisualStudioTestExplorerExtensions Restarted Visual studio
Test cases got discovered but not debugging
Upvotes: 14
Views: 44193
Reputation: 156
In my case, a .NET 8 project, I was seeing my tests in the test explorer, but no tests were ever run. A detailed trace showed that it found the test but then I got "no tests run".
The solution for me was that I needed not just 2, but 3 nuget references:
I hope this helps someone; I was tearing my hair out for hours.
Upvotes: 1
Reputation: 1
In my case i installed MSTest.TestAdapter in Nuget packages and after ı added attribute [TestClass] above my test class and it works.
Or you can use [Test] attribute for each test methods
Upvotes: 0
Reputation: 2005
I had may versions of the Nuget Package installed, I consolidated them into the latest one and it fixed the problem
I.e. instead of this:
MSTest.TestAdapter
MSTest.TestFramework
Use:
MSTest
"A meta package to simplify test projects."
Upvotes: 8
Reputation: 1428
As of today, me using NUnit @ VSCode and .NET Core 5.0 was missing Microsoft.NET.Test.SDK NuGet package.. As soon as I added it to ALL test assemblies (i.e.: all .csproj files in solution .sln), everything works fine. HTH to many who reach this far.
These PackageReferences are in my TestProject.csproj
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.1"/>
<PackageReference Include="NUnit.Console" Version="3.12.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0-beta.2"/>
<PackageReference Include="NUnitTestAdapter" Version="2.3.0"/>
<PackageReference Include="NUnit.Extension.NUnitProjectLoader" Version="3.6.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0-release-20210422-02"/>
</ItemGroup>
Upvotes: 4
Reputation: 1437
You can get this error message if you make the mistake of right-clicking inside the editor then choosing Debug Test(s)
when you are NOT in a unit test method (e.g. you have a method Foo()
and you put a breakpoint in there and want to run the tests so they cause the breakpoint to be hit...nothing will happen if you choose Debug Test(s)
while inside the body of Foo()
...you have to go to Test Explorer and choose Debug
or use the shortcut Ctrl+T,Ctrl+R
).
Upvotes: 0
Reputation: 3136
My issue was I was using async-await, and the return type was void. It needs to be Task. Changed this:
public async void MyTest()
To this:
public async Task MyTest()
Upvotes: 0
Reputation: 653
Also, make sure you have both MSTest.TestFramework AND MSTest.TestAdapter Nuget packages installed
Upvotes: 2
Reputation: 3660
If I understand you correctly, this is something you observe:
when you run the tests, the following can be seen in the console:
[4/3/2018 2:26:13 PM Informational] ------ Run test started ------
[4/3/2018 2:26:14 PM Warning] No test is available in d:\...\UnitTestProject1.dll. Make sure that test discoverer & executors are
registered and platform & framework version settings are appropriate and try
again.
and the test explorer shows:
What could have happened, and it happened to me a couple of times, that the test discovery is set up for another architecture than your currently set one.
Your current configuration is x64
but, the default test settings might have another one (e.g. x86):
If you _align the test settings with your current architecture (x86 → x64), the tests should run.
Manual cleanups should not be necessary nowadays, if the solution is configured consistently
Upvotes: 35
Reputation: 1411
I did below thing and it resolved my problem
%TEMP%\VisualStudioTestExplorerExtensions
Then test cases got discovered but not debugging.
It was giving error as:
Dependency finder domain): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'. Cannot find or open the PDB file.
and similar error for other DLLs as below:
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.TestPlatform.Common.dll'. Cannot find or open the PDB file.
So PDB is a debug information file used by Visual Studio. These are system DLLs, which you don't have debug symbols for.
Go to Tools->Options->Debugging->Symbols and select checkbox "Microsoft Symbol Servers", Visual Studio will download PDBs automatically.
Then I downgraded:
MSTest.TestAdapter.1.2.0 to 1.1.18
MSTest.TestFramework.1.2.0 to 1.1.18
Then restarted VS studio and rebuild.
Still got below error:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Then I set version to newVersion="4.0.0.0"
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.0.0.0" />
</dependentAssembly>
And it started debugging.
Upvotes: 0
Reputation: 191
I had same problem, make sure you set TestClass
to public
!
[TestClass]
public class CSharp_JavaScript_ServerResponse_Test
{
}
Upvotes: 15
Reputation: 81
Try clearing temp files located in the %TEMP%
directory
Delete folder : VisualStudioTestExplorerExtensions
in %temp%
directory.
Note: This path is generally at C:\Users\(yourusername)\AppData\Local\Temp
Upvotes: 3
Reputation: 5624
The accepted answer didn't work for me in isolation but along with this it did:
Upvotes: 6
Reputation: 1
Guys
I was having the same problem, and fix it by adding the [TestClass] and [TestMethod], and got my Selenium Automated test library working on VS 2015.
Cheers,
[TestClass]
public class GigHubAutomatedTest
{
[TestMethod]
public void StartApplication()
{
using(IWebDriver googleDriver = new ChromeDriver())
{
// 1. Maximize the browser
googleDriver.Manage().Window.Maximize();
googleDriver.Navigate().GoToUrl("https://www.google.com/");
}
}
}
Upvotes: 0