Tests not running in Test Explorer
Asked Answered
M

91

381

I am currently working on a solution that has currently 32 Unittests. I have been working with the resharper test runner - which works fine. All tests are running, all tests are showing the right test outcome.

However, the tests are not running when using the Visual Studio test explorer.

The Test Explorer is showing all unit tests, but once clicking on "Run All", all tests are getting greyed out and show no result of the test run:

enter image description here

  • All test classes are public
  • All test classes are having the [TestClass] attribute declared
  • All test methods are using the [TestMethod] attribute
  • Both the productivity code and the test projects are targeting .NET 3.5.
  • I have already tried to clean build my solution, and / or delete all obj, bin, Debug and Release folders

I'd appreciate any hints which would explain this behaviour.

Mcafee answered 29/4, 2014 at 11:14 Comment(15)
Update your ReSharper. Refer to this #16012275Retiarius
Wouldn't it be wonderful if VS said why a test was not run? Mismatched target platform, missing test adapter, ... :(Matsu
Where is it mentioned they use ReSharper ?Noach
@BernhardHofmann I encountered an issue just like this right now and it turns out that VS was spitting out some error messages in Output > Tests. Important. Frustrating that VS doesn't make them more visible, but that's a place to look in a situation like this.Nib
You all might be interested in upvoting this feature request: developercommunity.visualstudio.com/idea/947742/…Niel
Year is 2020, 5 years since this questions, and still after trying 10 different answers, I couldn't get the nunit tests to run. Creating a console project to run the test code. sighRooftree
So, very simple solution, as none of the answers actually helped... I had an syntax issue in by App.Config file for the test project.... Instead of <?xml version="1.0" encoding="utf-8"?> i had ?xml version="1.0" encoding="utf-8"?>Periphery
@BernhardHofmann Great reminder about Output > Tests. It'd definitely be so much easier if these details were surfaced by the "Not Run" message. i.e. "Not run because..." In my case, I had changed a TestMethod to async but not changed the return type from void to Task. I don't write these often enough to remember! Simple fix when you can find the error message!Accroach
I had this error in Output -> Test... "Multiple versions of same extension found. Selecting the highest version. Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter ..." So I had to update MSTest.TestAdapter and MSTest.TestFrameworkBilbe
Encountered this today because I had decorated an internal method with [TestInitialize]. Changed access modifier to public and the tests ran again. This post did not answer my question but helped me eliminate possibilities!Liquidator
In vs 2022, this issue happened when I created async void test method rather than async TaskMolybdic
Similar issue in VS 2022 .net6 project. Problem was that I didn't specify namespace (which is possible with file-scoped namespaces). Once namespace was specified at the top of the file, tests run in TestExplorer with no problem.Eroto
In my case the .NET Test Project compiled but would just show Not Run in Test Explorer. Seems one of the other projects it was referencing needed Microsoft.AspNetCore.Mvc.Core and cause it wasn't added to this test project it would just "not load" for testing. No indication of what package it was missing though. So painful.Coursing
Is your project under test targeting NetStandardx.x? If so, and you used Create Unit Test, the test project is set up to use NetStandard and tests are not exected. Change the test project target to Net7.0 or similar.Essieessinger
I have found that Mozilla VPN can cause the test explorer to fail tests when the dotnet test console app works just fine.Pulmonic
D
242

If your projects aren't all AnyCpu then you may also want to check that the following 2 settings match:

  1. [Right click test project] -> properties -> Build -> Platform target - e.g. x64

  2. [Main Menu] -> Test -> Test Settings -> Default Processor Architecture -> X64

I found that when these didn't match my test project would silently fail to run.

Derrick answered 13/3, 2017 at 13:36 Comment(9)
this one fixed my issues (switching from mixed platforms to anycpu)Obscure
make sure your testprojects are not netstandard2.0 but netcoreapp2.2Departmentalize
Worked. I really with VS would, you know, give us a clear warning or error message or something.Vitrescence
Temporarily changing the values and changing them back to Any CPU followed by hitting Save fixed it for me. Using VS 2019 Community Edition, in a project that was originally created in VS 2017.Souther
VS2019 version: Main Menu -> Test -> Processor Architecture for AnyCPU Projects -> X64.Tennison
I wish I could give you a bunch of likes. Thanks a lot.Cuspidor
I changed target framework from netstandard2.0 to net472 and it worked, thank you @MarcelStuder!!Actino
Only changing the Processor Architecture for AnyCPU Projects in the Test settings did not work, I (also?) had to change the PlatformTarget of the Test project.Housebound
I had unknowingly switch to a build config that wasn't building my test and target projects. This answer led me to my error!Anisometric
S
169

I had to change my async test methods to return Task instead of void.

The tests were then active and runnable in Test Explorer.

Sublet answered 5/7, 2018 at 10:55 Comment(7)
There is no way to wait for an async void method to finish. Async void is "fire and forget". That's why they cannot be tested.Receptor
The facepalming I did when I read this echoed over the land... Thanks for pointing out my stupidity. That worked for me. UpvotedBeefy
Although filed under the "no duh" category. I wish this could get up-voted more as its super obvious that your return type must be Task but easy to forget (because seemingly no other unit test in the world returns anything but void) and sends you down the rabbit hole of fixing your unit test configuration when there is no actual configuration problem. Really wish this just caused a compiler or the very least throws a runtime error.Misappropriate
@pat8719, sounds like a good idea for a code analyzer. They're not too hard to write. I just wrote out an xunit fact doing async void Foo() and their analyzers didn't complain, but they could certainly add one that would. cc: @bradwilsonMikkimiko
This was my problem, too. In VS 2019, it doesn't seem to happen with Xunit, though. But it always occur when using MsTest + async void.Cameron
This fixed mine.. Just spent ages looking into this!Serf
This solved it for me when converting from xunit to MSTest. xUnit can work with async void methods.Anti
O
150

If you are using NUnit rather than MSTest then you will need either the NUnit 2 Test Adapter or NUnit 3 Test Adapter for Visual Studio ≥ 2012/2013.

Outermost answered 30/4, 2014 at 7:16 Comment(11)
This helped me figure that that i needed to install the "NUnit 3 Test Adapter": marketplace.visualstudio.com/…Wulfila
In VS 2019 worked for me to install the adapter from the package manager nuget.org/packages/NUnit3TestAdapterXeres
According to this page you also need to install Microsoft.NET.Test.Sdk from NugetIlke
In VS 2017 I installed the Extension Nunit 3 Test Adapter and it worked.Ortolan
In VS 2019 I also installed the Extension Nunit 3 Test Adapter and it worked. One note: I also needed to update Visual Studio.Ortolan
+1 Thank you! Even with the latest version of VS 2019 16.5.5 I got no message at all that indicated what was wrong. It silently failed.Pampas
Installing NUnit3TestAdapter worked for me. I'm using VS 2019Levina
@BlueRaja-DannyPflughoeft - the missing Microsoft.NET.Test.Sdk was what was causing me problems. For some reason your comment was collapsed by StackOverflow, so I missed it initially. I've upvoted it now.Bjork
This helped me also for MSTest, although I had to install MSTest.TestAdapter NuGet Package instead of NUnit TestAdapterIonian
This was the issue for me when using XUnit, I needed to install xunit.runner.visualstudioSamarskite
This got me on the right path but I needed to install the "NUnit.Console" from the package manager as wellGlissade
C
101

I had the same problem in VS 2017. In my case it solved by restarting VS.

Cozmo answered 23/5, 2017 at 15:13 Comment(8)
my previous comment for why I gave this downvote was deleted, so I'll be a little clearer. This isn't a solution for the problem; it's a very temporary fix that doesn't solve the underlying issue. I don't think SO should be a place people should be coming to be told "turn it off and on again", that is knowledge to be learned way before you get here. Please see Joseph Simpson answer for a solution.Communistic
@Communistic I followd Joseph Simpson's answer and confirmed, that all my projects where AnyCpu. I still had the problem described here. For me simply restarting VS helped. That is not the first time VS2012 has these kind of hickups (and not only on my machine). I agree with you, that this isn't a good solution, but if there is nothing wrong with the project, that might be the only help. One should check if cleaning an rebuilding doesn't help either, though.Stoke
If only 'turning it on and off again' would fix all my problems. Still surprising how many it does fix. It's slightly embarrassing that I had to go to stackoverflow to be reminded to do it, but I found this answer useful.Herson
@lukka sometimes visual studio is the underlying problem and restarting is the solutionImpetus
For me, I had to install the xunit test runner that matched my xunit version. Then restart visual studio. Then it workedPleven
This step appears to be necessary when you manually unload/edit/reload the xxx.test.csproj file in VS2019 using Power Commands.Labannah
I had to close VS, then remove all bin and obj files and vs file, then start VS again, then it worked.Moat
Revisiting this thread every few years. This time I had VS 2022 17.4.0, all projects using x64, and I tried all the other tips here. Tests would not run. Restarting VS2022 resolved it immediately. No files were deleted.Ebenezer
I
94

You can view the error-output of your test runner by opening the Output panel (view-->output) and choosing "tests" from the "Show output from" dropdown

show output from


Additionally, if you have Resharper installed you can open a test file and hover over the test-circle next to a test to get additional error info

Resharper output

Clicking that will bring you to a window with more detailed information. Alternatively, you can open that window by going to Extensions --> Reshaper --> Windows --> Unit Test Exploration Results

Resharper Unit Test Exploration

Ilke answered 10/2, 2020 at 9:47 Comment(3)
The Test Output Log helped me to find an Exception deep down in Reactive Call Stack cause I had no mock for an Observable. Testing with Rx is quite challenging sometimes. But worth nonetheless.Inanition
This is a good way to troubleshoot the problem. In my case it was because... 'Method ClassCleanup has wrong signature'.Jacquelynejacquelynn
This helped me a lot. In my case the ClassInitialize method suddenly required a TestContext paramater, probably after a .NET version update at some point.Acheron
S
46

TLDR: Update the testing packages, look into the output -> test console

I struggled with this for a day and a half. so here's what I did to solve it:

Symptoms

  1. 5 Unit test projects, all discoverable in TestExplorer
  2. 2 out of 5 executed properly
  3. 3 stating not run at all
  4. The problem started after a .net framework update

Investigation

Since all the packages were updated during the .net framework update, I started with the differences between the working and not working projects. The first clue was that all 3 projects were using: MSTest.TestAdapter and MSTest.TestFramework

Naturally I went to the -> Output console -> Test dropdown in VS 2019 and looked at the output. Nothing useful there.

Step one of the solution: Update the MSTest.TestAdapter and MSTest.TestFramework to version 2.0.0

Step two of the solution: Now the Output console -> Test dropdown output started showing one after the other, missing packages and wrong binding redirects

Step three of the solution: Manually add the missing packages. For me those were

  1. System.Runtime.Extentions
  2. System.Reflection
  3. Maybe some more that I'm missing

Step 4 of the solution: Removed/Fixed the unnecessary binding redirects.

I hope this will help someone else.

Smote answered 16/11, 2019 at 8:22 Comment(5)
You saved me that day and a half! I upgraded a 4.5 FW version project and tried removing all unnecessary stuff from packages and ended up in this situation. Thanks!Assiut
I think I was experiencing something similar. Eventually I just re-created the project from scratch. Apparently there is a line in the *.csproj file that sets ToolsVersion and bumping mine messed everything up. All I can say is "buyer beware" for MS unit testing and be ready to replace your *.csproj files at a moment's notice this stuff is tightly integrated and very version dependent.Semiology
Thanks, while not directly my problem, the tip to check the console output showed me the error (DBContext Dispose method had an error in it) that was preventing my tests from running.Snaggy
Nice. I already had MS Test 2.x, but updating the test packages to the latest version (2.2.7) still fixed it for me.Bronwynbronx
Thank you so much! For me it was not the mstest adapter but a different version of NUnit3TestAdapter ! You brought me in the right direction!Signesignet
M
40

Check what framework the tests are written against (e.g. nunit, xunit, VS test, etc.) and make sure you've got the correct test adapter/runner extension installed.

For me it was NUnit 3 Test Adapter that was missing and I confirmed the version number required by looking at the nunit.framework dependency version (select the .dll in the Dependencies tree in Solution Explorer and hit F4 to bring up the Properties window).

Mikkimiko answered 1/8, 2018 at 15:2 Comment(3)
Note to self: My original MSTest proj ref'd Microsoft.VisualStudio.QualityTools.UnitTestFramework (unsure which version). Resolved issues where method not run (or found) by removing that ref, and installing the latest (v2.1.0) MSTest.TestAdapter (and Framework)Averill
@AdamCox Is Microsoft.VisualStudio.TestTools.UnitTesting deprecated? I had some tests using this that suddenly quit running as above after re-adding some references to a project they depended on.Semiology
@ebyrob, Athanasios' answer below might be relevant. Seems he not only had to upgrade/upgrade to the MSTest.* packages, but also add some dependencies and fix up some binding redirects. Check your warnings output.Mikkimiko
M
37

I found that in the project it was not referencing the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly. Instead, it was referencing Microsoft.VisualStudio.TestPlatform.TestFramework and Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions. When I removed those two references and added the reference to the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly the tests that were previously marked with the blue exclamation point suddenly became active and started working.

Unit tests not run with wrong assembly

With the right assembly, the tests run

Minium answered 24/10, 2019 at 15:23 Comment(4)
After switching from .NET Framework 4.6.2 to .NET Framework 4.7.2 my tests weren't running anymore. After hours of trying, only this solution worked for me.Cybill
After switching from .NET Framework 4.6.2 to .NET Framework 4.7.2 - I had to delete all the binding redirects in app.configCutlip
This fixed it for me as well! I also kept trying and realized from this post that Microsoft seems to be adding the wrong reference to the project when you create an MSTest UnitTest and its not recognized when you run in Visual Studio. Thanks so much for figturing this out!Buffybuford
This worked for me, a Great solution.. Our tests where just doing nothng. We removed those 2 and included the one and it worked perfectly.Franz
B
21

Install Nunit3TestAdapter Nuget has solved this problem

Bacchanal answered 6/1, 2020 at 10:13 Comment(1)
this fixed my issue as well! :)Hubey
A
19

Clean-Rebuild solution worked for me.

Adamis answered 29/5, 2019 at 12:9 Comment(0)
P
18

I had this issue and for me it was caused by having multiple Test Projects with different versions of :

  • MSTest.TestAdapter
  • MSTest.TestFramework

Consolidating the nuget packages for the projects so they were the same resolved the issue for me.

Pelagi answered 22/11, 2019 at 14:5 Comment(1)
This answer helped me find a similar cause. In my case some test projects had references to Microsoft.VisualStudio.TestPlatform.TestFramework (and did not run) while others had references to Microsoft.VisualStudio.QualaityTools.UnitTestFramework (which were the projects that would run).Algie
M
12

What fixed it for me was upgrading the MS.Test nuget packages

Mauritius answered 16/1, 2019 at 10:4 Comment(1)
Yes, for example when upgrading to .NET 6; everything will still compile, but those packages need to be upgraded tooFourthly
S
12

Had same issue after clean install of VS 2019. Tests are found but not run with "Unexpected error occurred". Fixed by setting up x64 instead of x86 which was selected by default.

enter image description here

Singlestick answered 23/12, 2019 at 10:39 Comment(2)
This was the fix for me, along with restarting VS and deleting the .vs folder. Thank you.Everetteeverglade
I can't believe that this is still a problem... Hopefully, Microsoft with output some kind of warning for that classic snag at one point.Unconventionality
I
10

In my case, it was because one test project in my solution had the MSTest.TestFramework and MSTest.TestAdapter nuget packages installed but the others did not. These packages were apparently not required to run tests until one project in the solution had them installed.

The issue was fixed by installing those packages on test projects missing them.

Isle answered 2/11, 2018 at 19:56 Comment(2)
In my case it's the exact opposite: Any unit test project, that has the MSTest nuget packages will not run, where as the others do. Strange.Whitleywhitlock
Solved: I have a .testsettings file. MSTest packages require a .runsettings file. That's why the tests aren't running.Whitleywhitlock
W
8

In my case I had an async void Method and I replaced with async Task ,so the test run as i expected :

    [TestMethod]
    public async  void SendTest(){}

replace with :

    [TestMethod]
    public async  Task SendTest(){}
Whitehall answered 10/11, 2019 at 7:8 Comment(1)
It's 2022 and I still had this problem. Why can't VS identify this problem and tell us? :/Conciliate
B
8

Have tried many options with Visual Studio 2019 Version 16.4.6 and Microsoft.VisualStudio.TestTools.UnitTesting, but for now the only way to run tests successfully was by invoking next command in console

dotnet test

Tests are discovered in Test Explorer but outcome is "Not Run".

Updating Visual Studio did not help.

Have resolved issue with "No test matches the given testcase filter FullyQualifiedName" by running updates to latest version for next packages:

Microsoft.NET.Test.Sdk
MSTest.TestAdapter
MSTest.TestFramework
Bug answered 16/3, 2020 at 16:37 Comment(1)
Yes! This was my problem. Thank you! I am using xUnit. I upgraded - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" /> And it started running my tests.Norvall
Z
7

enter image description here

Setting Processor Architecture for AnyCPU Projects in Test Explorer fixed my issue! See screenshot above.

Zizith answered 6/4, 2020 at 10:49 Comment(0)
T
7

I am using XUnit and was missing the xunit.runner.visualstudio package. Installing it and my tests ran.

Tickle answered 22/4, 2020 at 19:48 Comment(1)
Exactly the same situation I had issued. Installing xunit.runner.visualstudio fix the problem. My unit tests use xUnit, but Visual Studio said that nUnit Test Adapter could'nt find with that name. So installing this package solved it.Unbend
L
7

I managed to figure out the reason for VS 2019/2022 skipping some tests by running the test cli with blame option:

vstest.console.exe myproject-test.dll /blame

This will generate an xml file with one test with "Completed="False".

In my case, the test host process crashed due to a memory access violation while running that test. The memory access violation was caused by an infinite recursion. You can right-click and debug that certain test.

Lavalley answered 20/7, 2021 at 7:3 Comment(1)
This is underrated brilliant answer - I had a problem in the config file which I could only see with this solutionCleary
E
6

For me, the issue was my ClassInit() method did not have the right signature.

MSTest class initialization and clean-up attributes

In particular, note the [ClassInitialize] attribute on the ClassInit() method.

Works:

[ClassInitialize]
public static void ClassInit(TestContext context)
{

}

Did Not Work:

[ClassInitialize]
public void ClassInit(TestContext context)
{

}

or

[ClassInitialize]
public static void ClassInit()
{

}

or

[ClassInitialize]
public void ClassInit()
{

}
Edris answered 7/4, 2022 at 15:22 Comment(1)
This was my issue too, because I didn't need to touch TestContext context I was getting a warning in the IDE so I removed it. Which causes the tests to not run :facepalm:. So to fix it I added a SuppressMessage attribute for IDE00600 for the ClassInit function.Harbinger
W
5

With Visual Studio 2019 and test project targeting .NET 5.0 you need to install also xunit.runner.visualstudio. So, your packages should be like in this example:

  • xunit (2.4.1)
  • xunit.runner.visualstudio (2.4.3)
Wilhelm answered 23/10, 2021 at 12:17 Comment(1)
Thank you - this was my issueIncentive
R
4

Here it was the test project was not marked to be built:

Build -> Configuration Manager... -> check build for your test project

Reactance answered 10/1, 2019 at 17:34 Comment(0)
U
4

I had different version of NUnit (3.11.0) and NunitTestAdapter (3.12.0) nuget packages. When I updated NUnit to 3.12.0, Visual Studio ran tests.

Ulphiah answered 31/7, 2019 at 6:50 Comment(0)
L
4

In my case it worked to update the MSTest nuget packages. Could reproduce this problem even on blank MSTest project and updating the packages worked.

Libertinage answered 25/9, 2019 at 14:31 Comment(1)
I can confirm this works. At least for me. My tests were literally all working and then mid development they stopped and would not start. I tried several of the suggestions above: nothing. updating all the test packages restored function for me.Elasmobranch
S
4

Had the same symptoms, in my case it was the dotnet core SDK version that was the problem.

The projects was targeting 2.2, and was able to build using 3.0. After installing newest 2.2 SDK version they were able to run.

Szechwan answered 8/11, 2019 at 8:7 Comment(0)
B
4

I changed "Debug" to "Release" and it worked again (Any CPU.)

Brufsky answered 12/6, 2020 at 7:52 Comment(1)
I had the opposite work for me. Changed from release to debug and got my green ticksAppease
K
4

I had a different solution to get my tests to run. My global packages folder didn't match what was in my .csproj This is what my .csproj looked like: UnitTest .csproj

I had to change my Version to 16.5.0 which i found was installed in my global packages folder. Now my tests are able to run: .nuget folder explorer

Kultur answered 13/8, 2020 at 14:42 Comment(0)
I
4

What works for me is to delete the bin folder, then rebuild the project.

Illustrative answered 28/8, 2020 at 2:9 Comment(0)
C
4

When using both MSTests and NUnit tests it is possible to mix them. Also, remove other testing frameworks NuGet packages. Remove, Clean solution, Rebuild

This is the case:

[TestFixture]
public class NUnitTestClass
{
    [TestMethod]
    public void MSTestMethod()
    {
         // Will detect it but it won't run
    }
}
Composure answered 9/9, 2021 at 17:31 Comment(1)
Adding the [TestFixture] attribute solved my problemTrossachs
L
4

After struggling for hours on VS 2022, the solution for me was to install both: NUnit and NUnit3TestAdapter nuget packages

enter image description here

Lelandleler answered 22/7, 2022 at 20:57 Comment(0)
S
4

If you are using NUnit, please make sure to add the nuget package enter image description here

Note that use of VSIX Test adapters are deprecated in VS 2019, we recommend you to use the nuget versions of the adapter. this is from https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter

Sylvan answered 20/9, 2022 at 6:2 Comment(0)
A
3

I had same symptoms.

Please ensure you have the proper Visual Studio extension installed via Tools - Extensions and Updates. In my case, I had to install XUnit and Specflow from the Online option.

Then clean the solution and rebuild it.

If that still doesn't help, clear your temp directory (search for %temp% in the Start menu search and delete all contents in Temp)

And then finally try uninstalling Resharper which finally fixed my problem.

Adrianople answered 21/11, 2016 at 16:51 Comment(1)
Uninstall Resharper?! I don't think that this is a solution^^Aniela
M
3

Check in your project file for references to NUnit of different versions:

In my case, I had installed version 3.11.0 of both NUnit and NUnit3TestAdapter, but there were old references to version 2.6.4, in the project file, that weren't removed with the new installation.

  • Solution (Recomended to fix references issues, see docs):

    Reinstall NUnit and NUnit3TestAdapter, this fixed the references in my project.
PM> Update-Package NUnit -reinstall
...
PM> Update-Package NUnit3TestAdapter -reinstall
  • Solution 2 (In case of reinstalling didn't fix the references):

    Uninstall and install NUnit and NUnit3TestAdapter.
PM> Uninstall-Package NUnit
...
PM> Uninstall-Package NUnit3TestAdapter
...
PM> Install-Package NUnit
...
PM> Install-Package NUnit3TestAdapter
Moya answered 6/5, 2019 at 16:31 Comment(0)
A
3

This issue is also observed when the test method being run throws a StackOverflowException, making the test runner abort the test run, resulting in the output 0 tests run.

To find the culprit and solve it put a break point at the start of both TestInitialize and TestMethod decorated methods, run the unit test in debug mode, proceed stepping over (F10) until the exception is thrown.

Amy answered 8/1, 2020 at 17:15 Comment(1)
I had the same issue. I am in the middle of a code refactor and just a few tests were aborting due to this exception yet 160 of my 316 tests would not run at all. Further, if you run the nunit tests via the command line in PowerShell you'll see the StackOverFlow exception and can use that output to work on the debugAspergillosis
G
3

I had a slightly different scenario, but this is the top Google result so I'll answer my issue too. I could run the tests but only about half of them actually ran, with no error output.

Eventually I debugged and stepped through all the tests, and came upon a Stack Overflow Error when creating Test Instances of some models.

In the test instance methods, a child model created a parent and the parent created a child, which created an infinite loop. I removed the parent creation from the child, and now all my tests work!

Gallimaufry answered 18/5, 2020 at 19:6 Comment(1)
Thanks; I had a similar error; I'd mistyped a Parameter's name in the code I was testing... The test should have failed reporting that error; instead it showed as just not running.Scoles
B
2

For me solution was to change the Resharper Unit Testing settings "Default platform architecture" to "x64"

enter image description here

Barbur answered 1/7, 2018 at 23:6 Comment(1)
This solved my issue with a .NET Core 3.1 project that refused to execute tests in Test Explorer. Nothing else would fix it but this.Sleek
Q
2

Since I got here with this kind of error I post my problem/solution:

Symptoms:

  • Not all tests running, but they didn't depend per project, just some of them were executed.
  • All executed ones were green.
  • Tech stack: dotnet core / XUnit / FluentAssertions
  • All tests detected and updated if it changed.
  • By selection or running "Not runned tests" several times they could be executed.

Problem:

There was an error in the code that throw an exception inside another thread. All test assertions passed but it cancelled the test execution. I could see the error in the "Tests output" (NullException).

Quarta answered 14/3, 2019 at 11:6 Comment(1)
+1 I tried to debug a specific test. When I finally ran another, simpler test, then I could debug the specific test. This answer got me to try that.Godown
C
2

For me having a property called TestContext in a base class was causing this behavior. For example:

[TestClass]
public abstract class TestClassBase
{
    protected object TestContext { get; private set; }
}

[TestClass]
public class TestClass : TestClassBase
{
    // This method not found
    [TestMethod]
    public void TestCase() {}
}
Corneous answered 1/10, 2019 at 23:18 Comment(2)
I ran into a similar issue. TestContext needs to be a public property so the test runner can assign a new context to it.Aldred
private TestContext caused the same behavior in both VS and Resharper test runnersOrthostichy
L
2

There are already a lot of answers to this question, but I had a different scenario and resolution.

We moved functionality of a type being tested from one class to a new class, and as such created a new test class, with the old test class ending up being empty.

Original:

  • Old test class
    • Test initialize method
    • Test methods

Broken:

  • Old test class (initializer kept, class kept as placeholder for future)
    • Test initialize method (remains, by itself)
    • No test methods (the original test methods appear in test runner but don't exist in code so never execute)
  • New test class
    • Test initialize method
    • Test methods

Fixed:

  • Old test class (removed)
  • New test class
    • Test initialize method
    • Test methods

Clean the project, close Visual Studio, delete the TestResults folder, then restart VS, then rebuild the project. (This alone might fix your problem, but for me didn't suffice until a deleted the old test class.)

Lethargic answered 26/3, 2020 at 18:13 Comment(1)
"Clean the project, close Visual Studio, delete the TestResults folder, then restart VS, then rebuild the project. (This alone might fix your problem, but for me didn't suffice until a deleted the old test class.)" - Fixed it for me :)Broker
L
2

I added <PackageReference Include="NUnit3TestAdapter" Version="3.16.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference>

in my Test.csproj file

Lea answered 14/3, 2021 at 19:13 Comment(1)
I just added "NUnit 3 Test Adaper" in Extensions Manager of my Visual Studio 2019. NUnit adapter has disappeared for some reasons. I remember that I already ran tests a month ago. ))Affinal
C
2

Maybe it's an Infinite Loop.

Almost half of my tests were not running. The new changes I made to the code brought the tests to create an infinite loop. After fixing this issue (adding the correct arguments to the right method call) every test ran normally.

Hope this can help anyone - if you're adding new logic to someone else's code try debugging the tests that are not running, maybe you ran into an infinite loop too and VS just stopped the tests.

Colorful answered 22/7, 2021 at 11:34 Comment(0)
C
2

(I see this question already has many answers, but I couldn't find my scenario here.)

In my case (xUnit), the clue was in Visual Studio's "Test" output log (see screenshot below).

My NuGet packages were all updated - latest versions - to the point where I needed a (slightly 6.0.13 vs 6.0.12) newer version of .NET, which I didn't have installed.

I updated Visual Studio and managed to run the tests.

Tests fail because of .NET version

Cloaca answered 17/1, 2023 at 8:25 Comment(0)
A
2

In my case (VS 2022) - I installed MSTest.TestFramework first and could see the tests in test explorer, but they only went build and then nothing.

I performed the following steps until the problem was resolved:

  1. Update the project platform target to be x64
  2. Update the default CPU architecture to be X64
  3. I installed MsTest.TestAdapter
  4. I installed the Microsoft.Net.Test.SDK And only after all the above steps, my tests started running properly.

Note: After the problem was resolved, I reverted steps 1 & 2 back to how they were at the beginning, and the tests still ran fine, So probably in my case this thing was not necessary.

Allegraallegretto answered 2/6, 2023 at 3:1 Comment(0)
A
1

For me restarting VS2017 did not work. I had to clean sln then found a file with tests that didn't run and run that file only. After that I did run all and it worked normal again.

Alienor answered 8/11, 2018 at 19:28 Comment(0)
L
1

For me (not quite a solution) it was deselecting the .testsettings file in the Menu [Test]->[Test Settings]->[{current File}] to uncheck the currently used file.

In my case it starts so.

<TestSettings name="Local (with code coverage)" id="e81d13d9-42d0-41b9-8f31-f719648d8d2d" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Deployment>
    <DeploymentItem filename="ConfigurationImportExportTest\Configurations\" />
    <DeploymentItem filename="output\Debug\" />
  </Deployment>
  <Execution>

Apparently the DeploymentItem interferes.

because this was in the Output tab:

Warning: Test Run deployment issue: The assembly or module 'Microsoft.SqlServer.Management.SqlParser' directly or indirectly referenced by deployment item 'output\Debug\' specified by the test settings was not found.
.... more of the same

It does not tell me lots.
Seems like it has to do with the way that all projects put their compilation products in a common \output\Debug folder

however that seems not to hinder it. It puts out another warning mentioning things like

A testsettings or runsettings file with `ForcedLegacyMode = TRUE or VSMDI files are not supported by MSTest-V2.

That seems to stop it.

Lave answered 18/2, 2019 at 9:59 Comment(0)
H
1

I can tell from your attributes that you're using MSTest. I had a similar issue: my tests were showing up in the Test Explorer, but when I would try to run them (either by choosing Run All or individually selecting them) they would not.

My problem was that I had created the unit test project manually from an empty .NET Standard Class Library project. I had installed the MSTest.TestFramework NuGet package, but not the MSTest.TestAdapter package. As soon as I installed the adapter package, they ran as expected.

Seems obvious in retrospect, but when you create unit test projects from a template, you take these things for granted.

Headspring answered 9/11, 2019 at 21:26 Comment(0)
D
1

It is worth mentioning that sometimes NUnit Test Adapter files get corrupted in user folder C:\Users[User]\AppData\Local\Temp\VisualStudioTestExplorerExtensions\NUnit3TestAdapter.3.8.0/build/net35/NUnit3.TestAdapter.dll on Windows 10 and that causes Test Explorer to stop working as it should.

Decision answered 18/12, 2019 at 8:8 Comment(0)
F
1

I use VS2019 with .Net 4.7. I installed NUnit extension v3, and changed the Test settings to use X64. My unit test project is Any CPU (would work if I changed it to x64). Now I can debug through my code.

Forlini answered 6/1, 2020 at 23:38 Comment(0)
K
1

Well i know i am late to the party, but logging my answer here , incase, someone is facing similar issue as mine. I have faced this issue many times. 90% it gets solved by these two steps

project > properties > Build > Platform target > x64 (x32)

Test -> Test Settings > Default Processor Architecture > X64 (x32)

However i found one more common cause. The Solution files often change developer systems and they start pointing to wrong MSTest.TestAdapter. Especially if you are using custom path of nuget packages. I solved this issue by

  1. Opening the .csproj file in notepad.

  2. Manually correcting reference to MSTest.TestAdapter in import instructions like this.

Kourtneykovac answered 22/1, 2021 at 15:52 Comment(0)
N
1

Please make sure that you choose the right type of project. In my case, I chose the 'Unit Test Project' and I should have 'xUnit Test Project'. enter image description here

Nomen answered 31/5, 2021 at 9:0 Comment(0)
S
1

This problem occurred for me when creating a separate test project within Visual Studio 2022 for Mac (preview).

  • Repro Steps:
    • Open project in VS 2022
    • right click on solution, add new project
    • tests > nunit > continue
    • Target Framework: NET 6.0
    • Name : random-tests > create
    • VS 2022 for mac inclues a dependency for coverlet.collector - deleting this nuget reference fixed the problem for me.

solution-explorer

Sagittate answered 16/2, 2022 at 15:29 Comment(0)
D
1

The answer is:

Embedd NUnit3TestAdapter as Nuget Package additionally to NUnit. Thank me later

Deboradeborah answered 19/7, 2022 at 13:10 Comment(0)
A
1

Trivial but in my case, tests did not run because the constructor was private.

I found this under Tests in the Output window.

Anyhow answered 29/9, 2022 at 17:4 Comment(0)
S
1

Check Build for your Application Test at Configuration Manager:

screenshot

Sapphira answered 22/3, 2023 at 6:49 Comment(2)
Welcome to Stack Overflow! Thank you for contributing an answer. Could you please edit it to clarify what to look for in this screenshot and why this would solve the problem at the top of the page? See How to Answer.Honebein
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Stope
M
1

In my case it was because of wrong declaration of TestInitialize method. I had declared it as private static whereas it should be defined as public and non-static method as below:

[TestInitialize]
public void Initialize(){...}
Madalynmadam answered 20/8, 2023 at 18:48 Comment(0)
A
1

I had the same issue on testing xunit.

After installing enter image description here

it starts working.

Autobiography answered 19/2, 2024 at 8:48 Comment(0)
R
0

For me this was caused by a VS extension for measuring code coverage. It could not reference a particular assembly, and therefore would not run any of the tests. Tests would run fine from the command line using:

dotnet test

To solve this issue, you can opt to have ALL dependencies copied to your Test project debug folder. This ensures that any assemblies can be resolved, as "unused" assemblies are not removed. You can add the following to your Test projects .csprog file:

<PropertyGroup>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Reckless answered 4/7, 2019 at 17:0 Comment(0)
G
0

I solved my problem completely different to any of the solutions in here:

Each of my tests made a call to a function which in turn called itself meaning it'd not terminate:

public GoogleIntent CreateIntent(BotPath botpath)
{
    return CreateIntent(botpath);
}
Groundhog answered 7/11, 2019 at 11:2 Comment(0)
N
0

Upgrade your test project to the latest target framework version.

I was using Visual studio 2019 with target framework 4.5 whose support ended in 2016, jumping to 4.7 solved my problem.

Nurserymaid answered 28/11, 2019 at 17:18 Comment(0)
O
0

I had same issue after update to Visual Studio 16.4.1. Go to Test explorer -> Settings button -> Processor Architecture for AnyCPU projects -> x64

Oshea answered 16/12, 2019 at 8:16 Comment(0)
F
0

I had similar symptoms as OriolBG with the stack .Net Core/xUnit/FluentAssertions but for me updating the Microsoft.NET.Test.Sdk nuget package for the project did the trick.

Faustofaustus answered 2/3, 2020 at 13:22 Comment(0)
O
0

I had the same issue, but mine was resolved when I created a working copy on my actual desktop. The issue for me was because of the project folder was located on a network drive, and the dependencies were not able to load across the network drive for some reason. Hope this helps someone.

Oina answered 6/3, 2020 at 18:30 Comment(0)
F
0

Right click on the file in your solution explorer and make sure it's build action is set to "C# Compiler"

Solution Explorer --> Right Click File --> "Properties" --> Build Action = "C# Compiler"

enter image description here

Footnote answered 12/5, 2020 at 18:8 Comment(0)
G
0

Same issue. What was actually happening was that the test running was trying to discover tests in a web site project I have loaded (there was some jasmine specs for angular inside the site).

enter image description here

This was causing the runner to hang trying to load some NodeJS Container

Updating containers from Microsoft.NodejsTools.TestAdapter.TestContainer

enter image description here

I removed the website from the solution (obviously, just the solution, not deleting the website!)

I also had some corrupt configuration data that I had to clear out under the TestStore folder in the .vs directory.

Deleting the corrupted cache started the tests working again

After completing these two steps things magically started working again

Gathard answered 25/10, 2020 at 17:37 Comment(0)
B
0

Yet another ridiculous case: it somehow happened that two projects in the same solution had the same ProjectId - one of those was a test project and that confused Test Runner.

Removing and readding test projects to the solution changed the ProjectId and fixed the issue.

Byler answered 4/11, 2020 at 14:40 Comment(0)
M
0

I was having this issue also and my solution was that I needed to make the test class "public". I created the test class via the Create Unit Tests Wizard through VS2019 and by default it doesn't make it public.

Macadam answered 17/3, 2021 at 6:53 Comment(0)
F
0

I also faced this issue when I used selenium NUnit test in Visual Studio 2019 Community version 16.9.1. Some of the suggestions was to use older versions. But in my case the actual solution was to add Microsoft.NET.Test.Sdk" Version="16.0.1" package to the project.

Packages included in my project

Fantoccini answered 26/3, 2021 at 18:30 Comment(1)
Update the MSTest.TestAdapter and MSTest.TestFramework worked for meIceblink
Y
0

I chose "Debug Selected Tests" in place of "Run Selected Tests" from test explorer.

Yolandayolande answered 28/3, 2021 at 12:2 Comment(0)
T
0

Depending on the runtime installed, you may need to select:

[Right click test project] -> properties -> Build -> Platform target - e.g. x86

Setting it as x64 caused a "The framework 'Microsoft.NETCore.App', version '3.1.0' was not found." error in the test error output.

Tedra answered 1/5, 2021 at 20:17 Comment(0)
P
0

This worked for me in VS2019.

Moved Tests to a new NUnit 3 Test Project. All tests ran as is.

Peahen answered 24/5, 2021 at 14:10 Comment(1)
You are answering to a very old questions that has many answers. Please make sure to contribute something there that adds a new solution or insights.Algorism
C
0

I had a similar problem, tried all posted solutions with no luck. After 2 days eventually figured out that it was OneDrive causing the problem.

Turned off OneDrive, waited a bit, restarted VS, and BAM, was working again!

Cerebral answered 28/6, 2021 at 9:45 Comment(0)
B
0

Make sure you reference your test project with your main application project.

Berseem answered 5/7, 2021 at 19:35 Comment(0)
A
0

I had this issue, it turns out I left off "public" in front of the test class.

There is a warning for this under "Show output from: Tests"

"TestClass attribute defined on non-public class"
Adeline answered 24/8, 2021 at 1:5 Comment(0)
T
0

Initially I created test project with .Net library and added xunit and xunit.runner.visualstudio, but that didn't help me to run test cases.

Later created test project with xunit test project template, which automatically added coverlet.collector, Microsoft.NET.Sdk, xunit, xunit.runner.visualstudio nuget packages. Now am able to run test cases.

Tiein answered 24/8, 2021 at 2:53 Comment(0)
M
0

Was facing this issue, my project is huge and have tons of test cases so I had to figure out this

I uncheked the option "Discover tests in real time from c# and visual basic .net source files"

its under Tools->Options->Test->General

enter image description here

Mandi answered 8/9, 2021 at 4:28 Comment(0)
C
0

I had the same kind of problem in vs2022, but instead of getting blurred test results, the tests disappeared after running them. Also, no result was shown in the Test Explorer.

I could see that all tests worked in the Output window, but not on the Test Explorer Window where no test was shown.

In my case reinstalling vs2022 solved the problem.

Colfin answered 11/12, 2021 at 12:41 Comment(1)
You are answering to a very old question that has many answers. Please make sure to contribute something that adds a new solution or insights.Whitesell
C
0

I found a test project ran fine in resharper but ran nothing in vs test. The solution was missing nuget package xunit.runner.visualstudio

I guess the test project was developed by someone with resharper, so they were never aware it did not run in visual studio test explorer.

Catalinacatalo answered 18/2, 2022 at 12:25 Comment(0)
H
0

In my case needs to install Microsoft.NET.Test.Sdk

Hypercriticism answered 26/2, 2022 at 14:35 Comment(1)
There are sixty eight existing answers already, and several already mention this. Please upvote existing answers as a way of validating their feedback, instead of repeating their guidance.Pentheam
H
0

TLDR: Make sure all used projects are explicitly referenced

In my case I had a net461 unit test project that compiled fine and also ran fine when run from the Test Explorer explicitly.

When running 'all tests' or running 'not run tests', the test would stop halfway (when it got to the test in question).

Only output in test console:

========== Test run aborted: 270 Tests (270 Passed, 0 Failed, 0 Skipped) run in 5,1 sec ==========

When I converted the unit test project to netcoreapp3.1, the compiler complained about a missing project reference. It was referenced by another referenced project (hence implicitly available).

After the explicit project reference was added, I could revert back to net461, and all unit tests could be run from Test Explorer.

Hiatt answered 10/3, 2022 at 13:35 Comment(0)
F
0

I was able to resolve the problem of non-running Testcases by removing (commenting out) the DeploymentItem attributes to the TestMethods. Environment:

  • VS2022
  • net462
  • MSTest.TestAdapter 2.2.8
  • MSTest.TestFramework 2.2.8
  • Microsoft.NET.Test.Sdk 16.11.0
Fonda answered 22/3, 2022 at 10:22 Comment(0)
P
0

For .net core project, adding the reference to the following fixed the issue of tests not running or getting greyed out.

MSTest.TestAdapter

Preemie answered 23/8, 2022 at 13:2 Comment(0)
B
0

I deleted the .vs folder and Test Explorer started working!

Blackpool answered 9/10, 2022 at 9:59 Comment(0)
E
0

Following this article I found I had to add a reference and remove a package. I'm using vs 2022 but same goes for 2019. Found this page has the information to fix my issue. I found there are two ways to fix it.

I have framework 4.8 And reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework

The classes [TestClass] and [TestMethod] where visible because of a package installed, but adding that those attribute calsses where defined in the package and the added UnitTestFramework reference. Remove the package and showed it was ok running and debugging tests.

This is done another way by adding two packages. And you can add one package that will include the second.

Package Id's are: Microsoft.UnitTestFramework.Extensions MSTest.TestFramework

I believe the two package add is better than the one reference to assembly:

C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

Edwardoedwards answered 13/10, 2022 at 19:52 Comment(0)
K
0

I had the very same problem. A couple of questions first;

  • Do you use VS 2022?
  • Have you instsalled .net7 (preview) yet?
  • Do you use NUnit?

(This is at least what I have installed)

If so, then I might have found the solution. I came across this answer on GitHub: https://github.com/nunit/nunit3-vs-adapter/issues/987. I just updated my NUnit3TestAdapter NuGet package from version 4.2.1 to 4.3.0-alpha-net7.4, and now I can run all my tests again.

NuGet link: https://www.nuget.org/packages/NUnit3TestAdapter/4.3.0-alpha-net7.4

I found this error message in the Output tab > "Tests" in the dropdown, which helped me identify the issue:

No test is available in C:\xx\Tests\xx\bin\Debug\xx.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
NUnit Adapter 4.2.0.0: Test discovery starting
Exception System.TypeInitializationException, Exception thrown discovering tests in C:\xx\UnitTests\bin\Debug\UnitTests.dll
The type initializer for 'NUnit.Engine.Services.RuntimeFrameworkService' threw an exception.
   at NUnit.Engine.Services.RuntimeFrameworkService.ApplyImageData(TestPackage package)
   at NUnit.Engine.Services.RuntimeFrameworkService.SelectRuntimeFramework(TestPackage package)
   at NUnit.Engine.Runners.MasterTestRunner.GetEngineRunner()
   at NUnit.Engine.Runners.MasterTestRunner.Explore(TestFilter filter)
   at NUnit.VisualStudio.TestAdapter.NUnitEngine.NUnitEngineAdapter.Explore(TestFilter filter) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\NUnitEngineAdapter.cs:line 88
   at NUnit.VisualStudio.TestAdapter.NUnit3TestDiscoverer.DiscoverTests(IEnumerable`1 sources, IDiscoveryContext discoveryContext, IMessageLogger messageLogger, ITestCaseDiscoverySink discoverySink) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestDiscoverer.cs:line 82
InnerException: System.ArgumentException: Unknown framework version 7.0
Katmandu answered 27/10, 2022 at 9:10 Comment(0)
B
0

I've read through all the answers. Here's my magic solution that worked for my case.

tl;dr: check for undetected errors in the test project

  1. Make sure the test files in your test projects have no build error by scrolling through them and looking for red squiggly lines. Visual studio was compiling fine without any error, but actually the test project could not compile.
    Note that also that _the Output log did not report anything. I repeat, no errors were reported in any place (neither in the Error tab, nor in the Output log set to Build or Test) although were actually present and discoverable by reading through the test files and looking for red squiggly lines.
    Note that the only project that had undiscovered errors was the test project.

  2. Once I had fixed the errors, Visual Studio still wouldn't run the tests. Remove the test project from the solution.

  3. Add a new dummy test project. Compile and run it. Verify that the empty test in the new test project run successfully.

  4. Add back the original test project (without removing the dummy). Run all tests. At this point, the original tests started running again for me.

My configuration
  • Visual Studio Community 2022
  • NUnit tests findable but would not run
  • My solution had a large MAUI Hybrid project, some independent class libraries in .NET7, and a single test project.
For the record, other solutions I tried and did not help
  • Check the Output Log for errors.
  • Check the compatiblity of all nuget packages and project with the .NET version.
  • Restart VS
  • Most of the other solutions proposed in this thread
Boettcher answered 13/3, 2023 at 22:32 Comment(0)
D
0

I had this exact problem where I had 3 separate test projects, 2 of them ran without issue and the third one never ran, even if I tried to run the tests individually. There was no easy way to see what the reason was. The tests would not run on our YAML build pipeline in DevOps either.

Test project not running

Consolidate NuGet versions

First and foremost I would ensure your NuGet versions are consolidated for NUnit and NUnit3TestAdapter, to do this, right click the solution and click Manage NuGet packages for solution... go across to the Consolidate tab.

In my case the NuGet packages for NUnitTestAdapter were not aligned for the project that would not run, I consolidated those versions and then rebuilt the solution, ran all tests and now all 3 projects run successfully.

Check Output -> Tests

If the above doesn't work then I would suggest this step as it should output the exception being thrown by the test runner.

On the top bar select View and then Output (default shortcut Ctrl+Shift+U). Once this has opened change the drop-down for Show output from: to Tests, this should now give you the outputted logs from the test runner.

In my case the logs looked like this:

Multiple versions of same extension found. Selecting the highest version.
  NUnit3.TestAdapter : 4.3.0.0
Aborting test discovery because a test run was requested.
Discovery of tests cancelled.
The active test discovery was aborted.
========== Test discovery aborted: 0 Tests found in 3.9 sec ==========
Building Test Projects
Starting test discovery for requested test run
========== Starting test discovery ==========
Multiple versions of same extension found. Selecting the highest version.
  NUnit3.TestAdapter : 4.3.0.0
NUnit Adapter 4.3.0.0: Test discovery starting
Exception System.UnauthorizedAccessException, Exception thrown discovering tests in C:\Source\MainSolution\TestProject3.Tests\bin\Debug\net462\TestProject3.Tests.dll
Access to the path 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\InternalTrace.31504.log' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at NUnit.Engine.Internal.InternalTraceWriter..ctor(String logPath)
   at NUnit.Engine.Internal.InternalTrace.Initialize(String logName, InternalTraceLevel level)
   at NUnit.Engine.TestEngine.Initialize()
   at NUnit.Engine.TestEngine.GetRunner(TestPackage package)
   at NUnit.VisualStudio.TestAdapter.NUnit3TestDiscoverer.DiscoverTests(IEnumerable`1 sources, IDiscoveryContext discoveryContext, IMessageLogger messageLogger, ITestCaseDiscoverySink discoverySink) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestDiscoverer.cs:line 82
NUnit Adapter 4.3.0.0: Test discovery complete
No test is available in C:\Source\MainSolution\TestProject3.Tests\bin\Debug\net462\TestProject3.Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

The exception is being thrown by NUnit3TestDiscoverer.cs, at the start of the exception it mentions Multiple versions of same extension found. Selecting the highest version. NUnit3.TestAdapter : 4.3.0.0

There might be other exceptions being thrown in the logs, but in my case it was just the misalignment of NuGet versions.

Devan answered 28/4, 2023 at 15:23 Comment(0)
A
0

In my case, it was because I didn't have a public, default constructor in the test class. I had created a default constructor with an internal access modifier.

Anachronism answered 5/5, 2023 at 15:32 Comment(0)
B
0

All you need is to add this NUnit3TestAdapter nuget package to the project, then it will start picking up your tests

comment: In visual studio 2017 and above, if you use NUnit and see this message :

"No test adapters are referenced by this solution"

Bidget answered 8/5, 2023 at 18:33 Comment(0)
A
0

For me it was [ClassCleanup], the method needs to be static

Able answered 20/9, 2023 at 13:20 Comment(0)
A
0

For me deleting the bin, object, and VS folders fixed the problem.

Allantois answered 21/4, 2024 at 6:57 Comment(0)
B
-5

Try removing the [Ignore] attribute from above the test method.

Blazon answered 30/7, 2019 at 15:31 Comment(1)
The fact that the tests run in the Resharper test runner indicates that there is no [Ignore] attribute on them.Zagreb

© 2022 - 2025 — McMap. All rights reserved.