1

We have a utility project named Foo.Testing.Common with helper classes for our real test projects, named things like Foo.Tests.Unit and Foo.Tests.Integration. The Common project doesn't have tests, just base classes, utility methods and the like. It references XUnit so I can use Xunit.Abstractions.

How can we avoid seeing errors like the one below when we run all tests, either via .net command line or VS Test Explorer? The below error appears in VS Test Output during test discovery, for example.

No test is available in C:\Foo.Testing.Common\bin\Debug\netcoreapp3.1\Foo.Testing.Common.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException...

I assume the test process is matching on test to find test projects and then throws an error if one of those projects has no tests. Or maybe it's looking for projects that reference any xunit packages?

We could just rename the project, but is there a different way? Would like to avoid passing a list of specific test projects to the command line just to avoid the "no tests found" warnings. That is, dotnet test should just work.

Update: I've also tried referencing just xunit.abstractions and xunit.extensibility.core rather than the main xunit package, but the Common project still gets recognized as a test project.

Also tried setting IsTestProject to false in the project properties.

System.Cats.Lol
  • 1,620
  • 1
  • 26
  • 47

1 Answers1

5

In order to skip Foo.Testing.Common you can set IsTestProject property to false in Foo.Testing.Common.csproj:

<PropertyGroup>
  <IsTestProject>false</IsTestProject>
</PropertyGroup>
Andrii Litvinov
  • 12,402
  • 3
  • 52
  • 59
  • Unfortunately I'm still getting this error in test discovery output: `Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find C:\Foo\Foo.Testing.Common\bin\Debug\netstandard2.0\testhost.dll. Please publish your test project and retry.` I tried a rebuild and restarted VS too. – System.Cats.Lol Jul 23 '21 at 16:44
  • What version of SDK do you use? Can you share the csproj file? – Andrii Litvinov Jul 23 '21 at 18:04
  • 2
    We're also getting this issue and `IsTestProject` `false` does not work. I think we're using 6.0.200 or 6.0.402 – Jan Paolo Go Nov 10 '22 at 14:14
  • 1
    The issue on our end was that we have a custom `Directory.Build.targets` which sets `IsTestProject` `true` for projects that has a `Test` in its name – Jan Paolo Go Nov 10 '22 at 14:55