dotnet test runs library like test project

Viewed 118

I have a library where I defined Traits for filtering Unit tests in pipeline when running tests. To do that, I needed to reference xunit. This automaticly detects the project as a test project, even that there are no test and there is no testing nuget package "Microsoft.NET.Test.Sdk". And also I'm filtering the project when running dotnet test --filter Category=UnitTest and in pipeline I'm filtering by project name **/*.Tests.dll.

But dotnet test still treats the projects as a test project and fails because its not finding a "testhost.dll" assembly that I assume comes with the nuget package. Is this a bug? Can I configure the project to be detected as Library?

I tried setting Library or setting project Guids like it was done in the past.

I guess I can just add the nuget package and it will find no test, but I wonder why its detecting that project that neither matches the name nor has any tests.

Here the pipeline task:

  - task: DotNetCoreCLI@2
displayName: "Run Unit Tests"
inputs:
  command: 'test'
  projects: '${{parameters.workDir}}/**/bin/**/*.Tests.csproj'
  arguments: ' 
    -c ${{parameters.buildConfiguration}} 
    --no-restore 
    --no-build 
    --filter Category=UnitTest 
    -v detailed'

and the exact error message is "Unable to find [PathToWorkDir][subfolder\MyApp.HealthCheck.Tests\bin\Debug\net5.0\testhost.dll. Please publish your test project and retry."

Any ideas?

0 Answers
Related