VS2017 and NUnit 3.9 No test is available

为君一笑 提交于 2019-12-13 12:23:43

问题


I am using the latest VS2017 version 15.6.4, NUnit3TestAdapter 3.10.0 and Nunit version 3.9.0.0.

When I try to run a unit test in Test Explorer the test are grayed out, when I right click and and run selected tests I see the following error: No test is available Here is how my test class looks

    [TestFixture]
    public partial class ListViewBOTest
    {
    [Test]
     public void TestSearch_DateTime()
      {
        Assert.AreEqual(1,0);
      }

    }

Text from output:

[3/26/2018 10:53:55 AM Informational] ------ Run test started ------
[3/26/2018 10:53:55 AM Informational] NUnit Adapter 3.10.0.21: Test execution started
[3/26/2018 10:53:55 AM Informational] Running all tests in C:\Projects\MVPPlant\DEV\CMMSdg.Plant\CMMSdg.Plant\Sln.2010\CMMSdg.Plant.BusinessObjects.Test\bin\Debug\CMMSdg.Plant.BusinessObjects.Test.dll
[3/26/2018 10:53:56 AM Informational] NUnit failed to load C:\Projects\MVPPlant\DEV\CMMSdg.Plant\CMMSdg.Plant\Sln.2010\CMMSdg.Plant.BusinessObjects.Test\bin\Debug\CMMSdg.Plant.BusinessObjects.Test.dll
[3/26/2018 10:53:56 AM Informational] NUnit Adapter 3.10.0.21: Test execution complete
[3/26/2018 10:53:56 AM Warning] No test is available in C:\Projects\MVPPlant\DEV\CMMSdg.Plant\CMMSdg.Plant\Sln.2010\CMMSdg.Plant.BusinessObjects.Test\bin\Debug\CMMSdg.Plant.BusinessObjects.Test.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[3/26/2018 10:53:56 AM Informational] ========== Run test finished: 0 run (0:00:01.0435303) ==========

回答1:


I had the same problem as Amete Blessed and commenting out other Test methods made Test Explorer work and run my test




回答2:


Make sure you have installed the NUnit3 Test Adapter from here

https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter




回答3:


Can you check the following steps and see if it works?

  1. In the Visual Studio menu, go to Test > Test Settings > Default Processor Architecture and make a note if X86 is selected or X64
  2. Now go to the Build section in the Properties window of the project where the tests are written. Make sure the Platform target drop-down is selected to either Any CPU or at least it matches the architecture from the above step 1.

Now if you build the solution and try running those tests, you should see that they are now running.




回答4:


I found that my Build Events were wrong. Invalid copy command blew all my tests and half a day:

Copy C:\repo\Architecture\*.json $(ProjectPath)/Y
Copy C:\repo\Architecture\*.json $(TargetPath) /Y

instead of

Copy C:\repo\Architecture\*.json $(ProjectDir)/Y
Copy C:\repo\Architecture\*.json $(TargetDir) /Y



回答5:


The messages in the Test Output window ("NUnit failed to load [assembly]", "No test is available...", etc.) can hide the underlying issue that's causing the runner to not load the test assembly. This includes hiding failures to load dependencies of the test assembly or the item under test.

If there's a test assembly that's showing up in the Test Explorer window, but the tests refuse to run, it's worth temporarily enabling fusion logging to see if any assembly binding errors occur when trying to run the tests.




回答6:


After installing NUnit through nuget tests have appeared into Test Explorer but when I ran them I got "No test is available". Installing NUnit Test Adapter fixed the issue.




回答7:


You may have been a casualty of this problem that was (theoretically) resolved in 15.6.3. According to this answer, try deleting your %temp%\VisualStudioTestExplorerExtensions folder. That has resolved the issue for some other users.




回答8:


Rather than using the Test Explorer, can you right click on the solution and Run Unit Tests from there?




回答9:


I had similar problem when using Xamarin.Forms. The solution was to install NUnit.XForms from NuGet and add

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />

to csproj file of the project where the tests are.




回答10:


Had the same problem. In my case I found that the NUnit test adapter will not be used by Test Explorer if your test project contains a reference to MSTest. Typically the Microsoft.VisualStudio.TestPlatform.TestFramework.dll but also check your .csproj file for "MSTest" and your packages.config file.

I discovered this by first enabling diagnostic logging for Visual Studio tests. This is found under "Tools" -> "Options" -> "Tests" -> "Logging Level".

In my log I found this entry:

[22/11/2018 10:36:42 Diagnostic] Project C:\Git\myProject\src\myProject.Tests\myProject.Tests.csproj references test adapter: MSTest.TestAdapter, version 1.1.18




回答11:


What worked for me was to delete the ComponentModelCache folder located at %localappdata%\Microsoft\VisualStudio\<version>




回答12:


This is caused due to memory problem.

  • Clean object after test execution

Sample Code

private TestController testController;

[OneTimeSetUp]

public void TestSetup()

{

testController= new TestController();

}



[OneTimeTearDown]

public void TestCleanup()

{

testController= null;

}
  • Change test execution to 64 bits in settings

Test -> Test Settings -> Default Processors Architecture -> x64.




回答13:


I have also encountered the same issue.

Steps to resolve this issue -

 1. Install/Reinstall NUnit3TestAdapter package
 2. Delete Debug folder from the Bin
 3. Clean --> Build the project

Note - Also ensure all the packages are installed properly.

Now try to execute the tests.



来源:https://stackoverflow.com/questions/49495900/vs2017-and-nunit-3-9-no-test-is-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!