No test found. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again

感情迁移 提交于 2019-11-28 06:39:58
rubeonline

You can try to change your default processor architecture in your Test Setting from X86 to X64. In my case this was the problem.

This happens if the platform target of your project under test is set to x64.

My build was not finding the tests either. My setup and solution for finding the tests are as follows.

I use VSTS (Visual Studio Team Services) and have a build that is configured to refresh the NUGET packages on every build. I am using NUnit and found that running the following NUGET command (from the package manager console in Visual Studio) to add NUnitTestAdapter library to my test project and the checking in the packages.config made the tests run in my VSTS build.

Install-Package NUnitTestAdapter

As Maurice mentions in the Comment to this post for NUnit3 use the following NUGET package (Look for other utils on the link. i.e: dotnet CLI and Paket CLI)

Install-Package NUnit3TestAdapter

Hope this helps.

In my case, had to:

1) convert test proj to netcore 2.0 (was netstandard 2.0)

2) add nuget package xunit.runner.visualstudio

Reference: http://www.neekgreen.com/2017/11/20/xunit-no-test-is-available/

I got this error and was able to resolve it.

  1. I use Visual Studio Professional 2017
  2. In VS, I navigated to Tools --> Extensions And Updates
  3. At the top of the menu, I'd noticed that my NUnit adapter was disabled
  4. I clicked the [Enable] button
  5. I was able to initiate tests without errors.

I'm using MSTest. For me, it was version missmatch and missing another dependent package-

1) My package folder contains only MSTest.TestFramework.1.2.1 package. In my project file(.csproj) the reference in Target Name was MSTest.TestAdapter.1.2.0 package which was not present in package folder. My packages.config has also reference of MSTest.TestFramework.1.2.0 .

2) So I installed MSTest.TestAdapter.1.2.0 from nuget package manager and align MSTest.TestFramework version to 1.2.0 in project and package file. Finally I add Microsoft.VisualStudio.TestPlatform.TestFramework and Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions in the reference.

Then everything was OK. Hope this help someone.

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 ran into the same problem in VSTS with .Net 4.6.2. If you are seeing this from your VSTS console output, the workaround provided by @Sushil still works in VSTS and is needed. Unfortunately the "Test Assemblies" task provided by Microsoft passes, so you really don't even know there is a problem unless you check the output and find none of your tests actually executed!

I fixed this by issue in VS 2017 & 4.6.2 test project with the following steps:

  1. Remove references to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll and extensions
  2. Install the Microsoft.VisualStudio.QualityTools.UnitTestFramework.Updated nuget package
  1. Install Nunit and NUnitTestAdapter latest version from NUGET package.
  2. Go to ----> Test -----> Test Settings ---> Default processor architecture ------>Change to X64
  3. Build the solution.
  4. This will resolve Run Test and Debugger issue in unit testing and it will start working.

This is a known issue for .Net 4.6 now.

Unable to run .Net 4.6.x unit tests as part of a XAML TFS Build with TFS 2015 UPdate1 Source:https://connect.microsoft.com/VisualStudio/feedback/details/2245723

Here is a similar question for you reference: Unable to run .Net 4.6 Unit tests of TFS 2015 XAML build server

Make sure that you've got the "Microsoft.NET.Test.Sdk" nuget installed.

I was getting a similar issue and noticed somehow an app.config file had been added to my test project. Removing this config file fixed it for me.

I fixed this problem by reinstalling all testing related NuGet packages for the project: Xunit, Xunit.runner.vistualstudio, Microsoft.Net.Test.Sdk

I'll throw my solution onto the heap. In my case, I am adding a couple of projects to an existing solution along with Test projects for them. We're using MSTest. There was a previous UnitTest.testsettings file enabled on the solution that was causing compatibility issues.

Clicking on the settings file removed the check and the test run was successful for my tests.

Found a way! Probably not the most orthodox but it did helped me out in a hurry:

  1. Update the MSTest.TestAdapter and MSTest.TestAdapterFramework packages to the 1.4.0 from the Tools > NuGet Package Manager.
  2. The clean the solution and run the tests again.

I don't think is anything particular with the version, but updating it certainly cleans whatever reference is bad in the solution/project.

This is just to recap the solution brought forward by @Sushil earlier.

This is a known issue in Team Foundation Server 2015 RTM + Update 1 and will be fixed in Update 2, reference.

There is a workaround described by @Sushil here, which includes adding a .runsettings file that forces the test runner to older .Net framework (please not that you have to specify it through the "Add/Edit Test Run" dialog as adding it directly in the build process editor will be ignored).

Using .Net Core with a build pipeline in TFS 2017, my Visual Studio Test step was passing without actually executing any tests. Had to edit the step, "Advanced Execution Options" -> "Other console options" to include:

/framework:".NETCoreApp,Version=v2.0"

(That field also contains /platform:x64)

In Visual Studio 2017 I just uninstall and reinstall NUnitTestAdapter or install new package like NUnitTestAdapter.WithFramework package and problem gone.

I got this error because my Unit test class was not public.

Ex:

class ClientTests

Error in Output:

...\bin\Debug\Tests.dll] UTA001: TestClass attribute defined on non-public class ClientTests

Correction:

public class ClientTests

I faced the similar issue when tried nUnit in VS 2017 and it's not a core project. Installing NUnit3TestAdapter fixed the issue.

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.

In my case Reinstalling Nunit3 Adapter, Deleting temp folders, Changing architecture and nothing worked. Its because of the Daemon Resharper caused the problem.

Add or Remove Programs> Find Resharper > Repair > Install again > Restart VS 

That resolves the issues.

This error can happen for async tests if you have the wrong return type. The return type should be Task, and not void.

dixiashi

After add the TestAdapterPath in the commander, it's worked for me:

vstest.console.exe Xom.Gci.Lvf.FileParserInvoker.UnitTests.dll /TestAdapterPath:"C:\****\****\{SolutionFolder}"

In my case the tests were discovered but running resulted in "Test not Available..." and the (in)famous: "Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."

the error was independent of Visual Studio (tested from dotnet CLI tools and nearly naked UNit test) and it was only when targeting .NET 4.7.1. dotnetcore app works fine.

also running tests with the Nuint3 CLI nunit3-console.exe Tests.csproj shows the error:

"Either assembly contains no tests or proper test driver has not been found."

the error was because the test-adapter could not be found on a (mapped) network drive or share and was solved by copy it locally and rerun.

If you are running your tests inside docker using multistage building and tests aren't found. Make sure you copy all files not only project files like below Dockerfile section.

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY ["MainProject/FirstApp.csproj", "MainProject/"]
COPY ["TestProject/*", "TestProject/"]

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