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

41

166

I am in the process of upgrading our existing solution to .Net 4.6.1 and have been unable to get our unit tests to run during a server build. Locally they run as expected and flipping the framework version back to .Net 4.5.1 makes them run again on the server.

I am getting the following error:

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

I have reproduced the problem in a simpler setup:

  • Solution with a single C# Unit Test project with two tests (one failing, one passing).
  • XAML build definition using the Default Template (TfvcTemplate.12.xaml)
  • TFS 2015 Update 1 XAML build server with Visual Studio Enterprise 2015 Update 1 installed (have six similar servers and all produce the same result)
Could answered 14/1, 2016 at 13:2 Comment(4)
According to Brian Harry from Microsoft, this is bug they are currently investigating. It should be fixed in Update 2, and a temporary workaround should be posted later. Source: linkUndulant
I have the same problem for .Net 3.5 SP1 in Visual Studio 2013 Update 5.Bozcaada
@AndreyBushman: The error might be in 2013U5 too as it was released together with 2015RTM. But the workaround should work in your case too.Undulant
I had a similar problem, the workaround was simply in vs, under the test settings, to select the right default processer (32/64) bit, and no keep the engine runnig. (vs 2017.x)Hollister
A
1

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

Annaleeannaliese answered 16/1, 2016 at 8:8 Comment(1)
Hi Patrick. Both of the links you supply is cases opened by me, so I wouldn't trust them as reference ;-).Undulant
P
80

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.

Screenshot of test settings

Pendulum answered 28/5, 2018 at 18:29 Comment(3)
This solved it for me. In my case, both the project being tested and the test project were set to x86. Tests were disoverable but failed to run. After I changed it to Any CPU, tests ran.Goldshell
I just had the same problem and this resolved it. I am also quite suspicious that this may have had a bad nego-synergistic effect on my main project references, which suddenly stopped loading a particular DLL, but have not conclusively determined this nasty side effect.Niigata
Worked for me too, except that the menu was Test -> Processor Architecture for AnyCPU projects then select X64Footstone
U
73

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.

Unquiet answered 13/4, 2017 at 16:16 Comment(2)
I'm also currently using VSTS. As adviced I added NUnit3TestAdapter (since I'm using NUnit 3.8.1) and this solution solved my problem. Thank you :-)Aw
Install-Package NUnit3TestAdapter solved my issue :)Asymmetry
R
57

In my case, I had to:

  1. Convert test project 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/

Rozek answered 10/4, 2018 at 19:1 Comment(5)
same issue was with me. I am using xunit with .net coreAnnelleannemarie
This also worked for me in Visual Studio 2017 with xunit and .NET Core 2.1.Olgaolguin
in my case was a .net 4.6.1 project so the only thing missing was the xunit runner. Installed it and worked.Audriaaudrie
Same as Juan. Only the runner package was missing. Running this in the package manager for the test project solved it: install-package xunit.runner.visualstudioJannjanna
Confirmed. Accidentally removed the runner.visualstudio nuget package (keeping the xunit one). Re-introducing it fixed this problem. Thanks!Stylize
D
20

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.

Dalrymple answered 18/4, 2018 at 7:58 Comment(3)
I bumped into this with .Net 4.6.1 VS2017. I ended up rolling back to 1.2.0 - definitely make sure you dont have two different versions in your packages folder or in source control.Loafer
Mine appeared to find the tests, but yes, missing "MSTest.TestAdapter" was the real issue. No nice errors or warning (VS2017 15.8). All looked good except no tests were found, despite appearing in the test explorer..... So when I did "install-package MSTest.TestAdapter" suddenly my tests ran as expected. Thanks MS - 3 hours wasted...........Eddins
Installing the MSTest.TestAdapter 1.4.0 did it for me in VS 2019. I only wasted 30 minutes thanks to you.Barozzi
J
12

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

Jardine answered 28/11, 2018 at 10:19 Comment(1)
To add for others: yes, the xunit.runner.visualstudio package is needed to run Xunit tests with dotnet test, despite the name.Rusk
P
11

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.
Page answered 31/10, 2018 at 19:58 Comment(4)
Yes! And don't forget to restart Visual Studio. That was required for me.Gaea
"At the top of the menu" what does that mean?Aslant
@SaiyajinGohan. After you complete step 2, the "Extensions and Updates" window appears. At the top of this window, I saw the NUnit adapter was disabled. Hope this clarifies....Page
Thanks for that, I still couldn't get this working with the project I was working on. Luckily it was a test project and the next one worked. Still a mystery as to why.Aslant
F
7
  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.
Fifteen answered 29/11, 2018 at 8:47 Comment(1)
This actually worked for me after banging my head in so many directions and suggestions.Enjoin
A
6

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.

Axenic answered 5/4, 2018 at 13:48 Comment(0)
D
6

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.

enter image description here

Damon answered 16/1, 2019 at 21:9 Comment(0)
F
6

With net6.0 targetFramework I added these packages to .csproj-file:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.5" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.5" />

after which it started working. earlier versions may not be compatible with net6.0.

Do check the latest versions for the packages appropiate for your .NET version for example from nuget.org

Fabrikoid answered 13/6, 2022 at 12:27 Comment(0)
T
5

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!

VSTS Test Fix

Tetradymite answered 15/12, 2017 at 16:40 Comment(1)
My problem was with (on-prem) TFS 2015 Update 1 and it was fixed with Update 2. I am not sure if the same issue exist/existed with VSTS.Undulant
L
4

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

Linnealinnean answered 3/11, 2018 at 14:1 Comment(0)
H
4

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
Hosanna answered 12/6, 2019 at 12:22 Comment(1)
This did indeed bite me. I think the clue that this is happening is that it FINDS the unit test DLL, but it does NOT find any tests in it. I also found that putting this inline after your copy statements will let you inspect to see what WAS copied (here /app/tests is your target directory on the Docker image): RUN file="$(ls -al /app/tests)" && echo $file (see this post for more info on echo )Phobia
T
4

I solved this issue by installing NUnit3TestAdapter NuGet into my project (https://www.nuget.org/packages/NUnit3TestAdapter/).

dotnet add package NUnit3TestAdapter --version 3.17.0

My .csproj file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
    <PackageReference Include="NUnit" Version="3.12.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
    <PackageReference Include="RestSharp" Version="106.11.7" />
  </ItemGroup>

</Project>
Truncated answered 3/10, 2020 at 6:33 Comment(0)
I
4

This question is obviously being found by people with a range of scenarios, my answer will cover running XUnit tests on a .NET Core project using build pipeline on Azure DevOps but may help others too.

  • Ensure you have the XUnit test adapters installed from nuget as per this answer.
  • In the yaml for your build pipeline, add otherConsoleOptions: '/framework:.NETCoreApp,Version=v3.1' to the inputs of your VSTest@2 step (with the version number set to whatever version of .NET Core you are using). See this documentation for more info.
  • While this is not mandatory, I would recommend also adding failOnMinTestsNotRun: true so that the build pipeline will report a failure if zero tests are run.
  • If you run a build at this point, you may find that your tests run but the pipeline then gives the error The library 'hostpolicy.dll' required to execute the application was not found. You can solve this by changing your filter from the default **\*test*.dllto **\*test.dll (note the removed asterisk), or some other pattern which will match your test project's DLL. The reason for this is that XUnit places a file called testhost.dll in the output directory, as explained in this github issue.

If you are using the older pipelines which do not use yaml, the same options should be available. This answer covers adding the framework, I assume there will also be an option to "Fail the task if a minimum number of tests are not run" or something similar.

Intemperate answered 30/10, 2020 at 11:43 Comment(0)
C
4

I installed nunit3adapter package and it worked for me from my test log:
-->(NUnit3TestExecutor discovered 6 of 6 NUnit test cases using Current Discovery mode, Non-Explicit run)

Chose answered 22/11, 2021 at 14:51 Comment(0)
N
3

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
Neighbor answered 14/6, 2018 at 9:41 Comment(0)
C
3

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)

Counterproof answered 27/9, 2018 at 15:58 Comment(0)
P
3

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

Polemic answered 17/10, 2018 at 15:7 Comment(0)
P
2

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

Pinko answered 13/2, 2019 at 15:32 Comment(0)
U
2

I use MSTest.

I installed from Nuget the latest version of MSTest.TestFramework and replaced OOB Remove references to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

Then Installed from neget the latest version of Microsoft.TestPlatform

It allowed me to run test with a command:

".\packages\Microsoft.TestPlatform.16.6.1\tools\net451\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" "UnitTestProject1\bin\Debug\UnitTestProject1.dll" /logger:trx

But I got the same error. The root cause of the error that I didn't specify a test adapter which parses the assembly and finds tests.

Solution:

  1. Install a nuget package "MSTest.TestAdapter"

  2. Specify a test adapter in the end of a command:

    /TestAdapterPath:".\packages\MSTest.TestAdapter.2.1.2\build_common"

Uteutensil answered 1/7, 2020 at 16:48 Comment(1)
Updating MSTest.TestAdapter (2.1.2->2.2.7) and MSTest.TestFramework (2.1.2->2.2.7) fixed it for me. Thanks!Anallise
E
2

I have just been through this issue. It seems there may be a lot of causes for it. In my case, I was trying some codes and due to that, I renamed the project, removed it.. added it again... and all of a sudden, my single test stopped working and the Test output window was showing this error: "No test found. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again" The Debug output was showing errors related to the platform: "Following dll(s) do not match current settings, which are .netframework , version 4.5 and platform X86."

Using VS 2019 v 16.8.0 Test project on .NET Framework 4.8 Configured to Debug/Any CPU

After trying a bunch of things, the solution was

  • Close Visual Studio
  • Rename the folder holding your solution. For example: C:\Git\Solution to C:\Git\Solution2
  • Open VS and load your solution. Try to run a test.

This worked for me, hope it works for you.

Euphonious answered 28/3, 2021 at 5:21 Comment(1)
This worked for me. The error was strange after updating to latest version of VS2022. Installing any new libraries didnt help me.Menorrhagia
A
1

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

Annaleeannaliese answered 16/1, 2016 at 8:8 Comment(1)
Hi Patrick. Both of the links you supply is cases opened by me, so I wouldn't trust them as reference ;-).Undulant
C
1

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).

Could answered 4/2, 2016 at 9:14 Comment(0)
H
1

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.

Huber answered 27/9, 2018 at 14:12 Comment(0)
C
1

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

Chouinard answered 30/9, 2018 at 8:2 Comment(0)
P
1

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

Persia answered 2/11, 2018 at 21:45 Comment(0)
J
1

I am having the same issue. I am using Visual Studio 2017 Community Edition.

enter image description here

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.

Juliettejulina answered 8/1, 2019 at 23:0 Comment(0)
F
1

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.

Femmine answered 8/4, 2019 at 14:14 Comment(0)
A
1

Try running vstest.console.exe with --diag:diag.txt and inspect the output. For me it was DLL load failures for test adapters from my working directory:

TpTrace Information: 0 : 14976, 1, 2020/03/10, 15:34:22.120, 57158093583, vstest.console.exe, AssemblyResolver.OnResolve: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter: Failed to load assembly. Reason:System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Directory\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

File name: 'file:///C:\Directory\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

I worked around this by adding <loadFromRemoteSources enabled="true"/> under <runtime> in vstest.console.exe.config

Adjectival answered 10/3, 2020 at 20:4 Comment(0)
C
1

I've recently run into this issue as well, and I can with some confidence state that it's not one covered by any of the other answers here.

I've recently been writing some F# modules that (for reasons) have signature files. Again, for reasons, I've had to put unit tests into the same module.

When an F# source file is 'covered' by a signature file, only the declared values are exported. Thus, you have to explicitly declare each and every test in the signature file as well, otherwise you'll get the error message in the OP.

Cheryle answered 13/12, 2022 at 17:26 Comment(0)
S
1

One more random thing to do is to add the file xunit.runner.json.

Example configuration:

{
  "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
  "appDomain": "ifAvailable",
  "shadowCopy": false,
  "parallelizeTestCollections": false,
  "maxParallelThreads": 1
}

Don't forget to include it in the project:

<ItemGroup>
  <Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

In my case, this was the magical remedy.

Spellbind answered 16/1, 2023 at 12:59 Comment(0)
I
1

With NUnit3, in most cases all I had to do was to add

<PackageReference Include="NUnit3TestAdapter" Version="4.x.x" />

However in some of .NET Framework 4.7.2 SDK-style tests projects that wasn't enough.

The issue was with PlatformTarget project property. If unspecified it defaults to AnyCPU, however NUnit seems to always fail with

No test is available in Foo.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

if it was left unspecified.

So, besides the PackageReference, I had to either:

  • Just set <PlatformTarget>x86</PlatformTarget>.
  • Explicitly set <PlatformTarget>AnyCPU</PlatformTarget> (even though it is AnyCPU if unspecified) and then in Test tab set "Processor Architecture for AnyCPU Projects" to "x86". Setting Processor Arhitecture for AnyCPU Projects
Inexhaustible answered 28/3, 2023 at 9:4 Comment(0)
P
0

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.

Purr answered 28/1, 2019 at 17:10 Comment(0)
C
0

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

vstest.console.exe Xom.Gci.Lvf.FileParserInvoker.UnitTests.dll /TestAdapterPath:"C:\****\****\{SolutionFolder}"
Childers answered 8/5, 2019 at 5:59 Comment(1)
First things, you should make sure that the test case can be run in the VS IDE.Childers
W
0

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.

Whitson answered 17/5, 2019 at 14:37 Comment(0)
P
0

For me the problem was an old reference to Microsoft.VisualStudio.TestPlatform. You don't need an explicit reference to this package because MSTest.TestFramework has a transitive reference to this package with a correct version.

Prosenchyma answered 11/1, 2023 at 15:21 Comment(0)
G
0

If your solution only has one test file, check it has the .cs file extension.

I used the dotnet command to create a new test project for myself. I hastily renamed the generated class (UnitTest1.cs) without the .cs file extension.

This is similar to @Jared-Beach's scenario: obviously no tests were found via the IDE nor the command line. Beyond the first three words, the rest of the error message will point you in the wrong direction.

Godlike answered 22/1, 2023 at 17:22 Comment(0)
M
0

I got this error because I had accidentally changed the Tests.cs file Compile action to 'None'.

Mitziemitzl answered 11/7, 2023 at 8:5 Comment(0)
B
0

In my particular case I had loaded the same file twice.

  1. Unload your project.
  2. Check that you aren't loading the same file twice. If you are, just delete the file.
     <ItemGroup>
       <Compile Include="TitleBlockSizerTests.cs" />    
       <Compile Include="TitleBlock\TitleBlockSizerTests.cs" />   Notice how this file is listed twice?
     </ItemGroup>

Notice how the same file is included twice? Once that was removed, the tests ran fine.

Buckley answered 11/10, 2023 at 19:41 Comment(0)
C
0

Make sure that your test adapter .dll file is located in the directory alongside the *.Test.dll files you intend to test. In my case, I needed to configure the pathtoCustomTestAdapters parameter of the VSTest@3 task to point to the directory where the test adapter .dll was copied. In my scenario, this directory was $(Agent.BuildDirectory)\References\Client.Debug\. This necessity arises from the specific logic of my solution, where nearly all generated dlls, including the test adapter's dll, are copied to this designated directory.

Conjoin answered 15/12, 2023 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.