question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VS2019 shouldn't write Warning "No test is available" when that's expected

See original GitHub issue

In Visual Studio 2019, when I (re)build my C# project, the Tests section in the Output window shows the following warning:

[8/13/2019 9:58:08.397 AM Informational] ---------- Discovery started ----------
[8/13/2019 9:58:09.564 AM Warning] No test is available in H:\Foo\src\bin\Release\net461\Foo.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[8/13/2019 9:58:09.612 AM Informational] ========== Discovery finished: 0 tests found (0:00:01.2086584) ==========

I have a separate project which contains my unit tests. Foo.dll will never contain tests. How can I avoid this assembly/project being scanned for tests and causing that warning message from being written?

Here is the full diagnostic log:

[8/13/2019 10:41:36.704 AM Diagnostic] Pausing Queue..., current operation is: no current operation
[8/13/2019 10:41:36.705 AM Diagnostic] Enqueue operation 'WaitForBuildOperation', hashcode:43196519 
[8/13/2019 10:41:36.705 AM Diagnostic] Operation left in the the queue: 1
[8/13/2019 10:41:36.705 AM Diagnostic] 	'WaitForBuildOperation', hashcode:43196519
[8/13/2019 10:41:36.705 AM Diagnostic] 

[8/13/2019 10:41:36.705 AM Diagnostic] Operation Dequeue : 'WaitForBuildOperation'
[8/13/2019 10:41:54.416 AM Diagnostic] Container Discoverer 'Microsoft.VisualStudio.TestWindow.Client.TestContainer.ProjectOutputContainerDiscoverer' has container changes
[8/13/2019 10:41:54.632 AM Diagnostic] test container discoverer executor://projectoutputcontainerdiscoverer/v1, discovered 1 containers
[8/13/2019 10:41:54.633 AM Diagnostic] Containers from 'Microsoft.VisualStudio.TestWindow.Client.TestContainer.ProjectOutputContainerDiscoverer' :
[8/13/2019 10:41:54.634 AM Diagnostic] 	H:\Foo\src\bin\Release\net461\Foo.dll
[8/13/2019 10:41:54.646 AM Diagnostic] Enqueue operation 'DiscoverSelectedOperation', hashcode:63023693 
[8/13/2019 10:41:54.646 AM Diagnostic] Operation left in the the queue: 1
[8/13/2019 10:41:54.646 AM Diagnostic] 	'DiscoverSelectedOperation', hashcode:63023693
[8/13/2019 10:41:54.646 AM Diagnostic] 

[8/13/2019 10:41:54.646 AM Diagnostic] Operation Dequeue : 'DiscoverSelectedOperation'
[8/13/2019 10:41:54.646 AM Diagnostic] DiscoveryOperation<DiscoverSelectedOperation> FinishedChangedCotainers, changed container count is 1
[8/13/2019 10:41:54.647 AM Diagnostic] Discovering the following containers :
[8/13/2019 10:41:54.647 AM Diagnostic] 	H:\Foo\src\bin\Release\net461\Foo.dll
[8/13/2019 10:41:54.653 AM Error] System.InvalidOperationException: The operation failed as details for project DotNetCore could not be loaded.
   at NuGet.PackageManagement.VisualStudio.NetCorePackageReferenceProject.GetPackageSpecsAsync(DependencyGraphCacheContext context)
   at NuGet.VisualStudio.VsPackageInstallerServices.<GetPackagesPathResolverAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.VisualStudio.VsPackageInstallerServices.<>c__DisplayClass7_0.<<GetInstalledPackages>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)
   at NuGet.VisualStudio.VsPackageInstallerServices.GetInstalledPackages()
   at Microsoft.VisualStudio.TestWindow.Controller.UnitTestExtensionDiscoverer.GetNugetAdapters()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
[8/13/2019 10:41:54.654 AM Informational] ---------- Discovery started ----------
[8/13/2019 10:41:55.056 AM Diagnostic] TelemetrySession: Creating the event: VS/UnitTest/TestWindow/Ext/RunSettingsService 
[8/13/2019 10:41:55.056 AM Diagnostic] Event:VS/UnitTest/TestWindow/Ext/RunSettingsService key: VS.UnitTest.TestWindow.RunSettingsService.Name value:VSTest Run Configuration
[8/13/2019 10:41:55.057 AM Diagnostic] TelemetrySession: Creating the event: VS/UnitTest/TestWindow/Ext/RunSettingsService 
[8/13/2019 10:41:55.057 AM Diagnostic] Event:VS/UnitTest/TestWindow/Ext/RunSettingsService key: VS.UnitTest.TestWindow.RunSettingsService.Name value:TestPropertySettingsForBoostAdapter
[8/13/2019 10:41:55.057 AM Diagnostic] TelemetrySession: Creating the event: VS/UnitTest/TestWindow/Ext/RunSettingsService 
[8/13/2019 10:41:55.057 AM Diagnostic] Event:VS/UnitTest/TestWindow/Ext/RunSettingsService key: VS.UnitTest.TestWindow.RunSettingsService.Name value:TestPropertySettingsForGoogleAdapter
[8/13/2019 10:41:55.058 AM Diagnostic] TelemetrySession: Creating the event: VS/UnitTest/TestWindow/Ext/RunSettings 
[8/13/2019 10:41:55.058 AM Diagnostic] Event:VS/UnitTest/TestWindow/Ext/RunSettings key: VS.UnitTest.TestWindow.RunSettings.Services value:3
[8/13/2019 10:41:55.063 AM Diagnostic] File timestamp changed from 8/13/2019 10:02:25 AM to 8/13/2019 10:41:51 AM for H:\Foo\src\bin\Release\net461\Foo.dll
[8/13/2019 10:41:55.099 AM Diagnostic] Grouped H:\Foo\src\bin\Release\net461\Foo.dll : (AnyCPU, Framework45, net461, )
[8/13/2019 10:41:55.100 AM Diagnostic] Test discovery settings for H:\Foo\src\bin\Release\net461\Foo.dll:
 <RunSettings>
  <RunConfiguration>
    <ResultsDirectory>H:\Foo\TestResults</ResultsDirectory>
    <SolutionDirectory>H:\Foo\</SolutionDirectory>
    <TargetPlatform>X64</TargetPlatform>
    <CollectSourceInformation>False</CollectSourceInformation>
  </RunConfiguration>
</RunSettings>.
[8/13/2019 10:41:56.570 AM Warning] No test is available in H:\Foo\src\bin\Release\net461\Foo.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[8/13/2019 10:41:56.712 AM Informational] ========== Discovery finished: 0 tests found (0:00:02.0181408) ==========
[8/13/2019 10:43:20.516 AM Diagnostic] TelemetrySession: Creating the event: VS/UnitTest/TestWindow/FirstToolWindowInteraction 

This is Visual Studio Professional 2019 16.2.1 on Windows 10

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nohwndcommented, Jan 16, 2023

VS does use vstest for discovery, but vstest does not inspect the dll to ensure that it in fact IS a test dll. Instead VS uses a set of criteria to determine if a project is a test project and sends the target dll to vstest for discovery. We then assume that there should be tests and print warning when there are none. We cannot distinguish between a dll that is not supposed to have tests, and one that has no tests because of misconfiguration.

VS scans the project for known dependencies (like depending on nunit), and I thought also for

<TestProject>false</TestProject>
<IsTestProject>false</IsTestProject>

but that does not seem to work. So this simple console app will always be scanned for tests (and fail because I don’t include any adapter).

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <TestProject>false</TestProject>
    <IsTestProject>false</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NUnit" Version="3.13.3" />
  </ItemGroup>

</Project>

So this is out of our control. Please fill a VS feedback for this. if there are more problems please create a new issue and reference this, rather than reviving a closed issue from 2019.

1reaction
devinvisiblecommented, Aug 13, 2019

The InvalidOperationException seems to be a nuget issue when the project has multiple target frameworks and conditional assembly name:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
    <AssemblyName>Foo</AssemblyName>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TargetFramework)'=='net461'">
    <AssemblyName>Foo4</AssemblyName>
  </PropertyGroup>
</Project>

The workaround I’ve used is to introduce a src\Microsoft.Common.props file that contains: <PackageId>$(MSBuildProjectName)</PackageId>

With the InvalidOperationException gone, my Tests output has changed a little; it now says that the assembly contains no NUnit 3.0 tests but it then writes out a warning.

[8/13/2019 4:12:09.395 PM Informational] ---------- Discovery started ----------
[8/13/2019 4:12:11.111 PM Informational] NUnit Adapter 3.10.0.21: Test discovery starting
[8/13/2019 4:12:11.367 PM Informational] Assembly contains no NUnit 3.0 tests: H:\Foo\src\bin\Release\net461\Foo4.dll
[8/13/2019 4:12:11.372 PM Informational] NUnit Adapter 3.10.0.21: Test discovery complete
[8/13/2019 4:12:11.382 PM Warning] No test is available in H:\Foo\src\bin\Release\net461\Foo4.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[8/13/2019 4:12:11.509 PM Informational] ========== Discovery finished: 0 tests found (0:00:02.0412323) ==========

I want this project / assembl[y|ies] to be omitted or ignored. I expect there to be zero tests. I don’t want to see that warning message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why will Visual Studio 2019 will not run my unit tests?
The problem is that parameterized tests do not "exist" in source code but are generated by the test adapter at runtime.
Read more >
Tests not running in Test Explorer
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...
Read more >
No longer able to group by trait in Test Explorer with VS ...
I just installed 16.2 (no preview) and it is not fixed there. Please reopen, old version of Test Explorer allowed to group by...
Read more >
Configure and use Live Unit Testing - Visual Studio
Tests only run when a change to the test or the test's dependencies is detected. If there's no change, it avoids unnecessarily running...
Read more >
C4267 gets reported at /W0 - Developer Community
C4267 is level 3 warning so it shouldn't be shown when compiler is set to lower warning level. Most of the time warning...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found