visual-studiounit-testingtestingmstest

No tests found to run - while debugging/running Unit test cases -- Visual studio 2017 15.5.1


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


Solution

  • Problem

    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:

    no test found to run

    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.

    Example

    Your current configuration is x64

    current configuration

    but, the default test settings might have another one (e.g. x86):

    default test settings

    Solution

    If you _align the test settings with your current architecture (x86 → x64), the tests should run.

    successful run

    Manual cleanups should not be necessary nowadays, if the solution is configured consistently