No test assemblies found matching the pattern: **\*Test*.dll,!**\*TestAdapter.dll,!**\obj\**

Viewed 15847

I am trying to implement a Gated Check-In process in Azure DevOps (VSTS) based on the success of the unit tests. However, I am consistently getting this warning/error that assemblies are not found.

##[warning]No test assemblies found matching the pattern: **\*Test*.dll,!**\*TestAdapter.dll,!**\obj\**.
##[debug]Processed: ##vso[task.issue type=warning;]No test assemblies found matching the pattern: **\*Test*.dll,!**\*TestAdapter.dll,!**\obj\**.
======================================================

All my unit tests run successfully in Visual Studio 2017 in Test Explorer locally.

The Azure DevOps documentation seems straightforward but it does not work when I follow it.

I am using a Hosted VS2017 Agent. The CI Build itself succeeds upon check in to TFS source control.

Log

screen 1
screen 2 screen 3 screen 4 screen 5 [screen 6]

4 Answers

The "old" .NET had the files located in the Release folder (which is described by the BuildConfiguration variable).

.NET Core builds contain an extra folder:

Folder structure

YourNamespaceHere.UnitTests > bin > Release > netcoreapp2.1 > dll's

When you add an extra wildcard, the build will find the unittest dll's.

**\$(BuildConfiguration)\*\*unittests.dll

I have renamed the *Tests* part to *unittests.dll as my project also contains integrationtests.

enter image description here

I had this same problem in a .Net Core 2.1 project. In the "other console options" you want to add:

/Framework:.NETCoreApp,Version=v2.1 /logger:console;verbosity="normal"

Please be aware that I had another problem not related to this, but on the same task. I was getting an error about not finding a test file result output for the TestPlatform dlls. So, I added this filter to the existing test files:

!**\*Microsoft.VisualStudio.TestPlatform*

My final yaml looks like this:

- task: VSTest@2
  displayName: 'Run Unit Tests'
  inputs:
    testAssemblyVer2: |
     **\$(BuildConfiguration)\*test*.dll
     **\$(BuildConfiguration)\**\*test*.dll
     !**\*Microsoft.VisualStudio.TestPlatform*
     !**\obj\**
    vstestLocationMethod: 'location'
    vstestLocation: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\'
    codeCoverageEnabled: True
    otherConsoleOptions: '/platform:x64 /Framework:.NETCoreApp,Version=v2.1 /logger:console;verbosity="normal" '
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

I had the same issue when my Unit Test task wanted to run (I'm using .Net Core). It seems like a path naming issue. My Unit Test project is called

SimpleExample.UnitTests

but the path of "DotNetCoreCLI@2" task in the YAML file was set to

'**/*Tests/*.csproj'

So I just change the project path of the unit test task to be like the second part (after dot) of my Unit Tests project in Visual Studio.

The path of my unit test project in Visual Studio 2017: Desktop\Azure-DevOps-Test\SimpleExample.UnitTests

The YAML task that runs the unit tests [For .Net projects]:

- task: DotNetCoreCLI@2
    displayName: 'Runing Unit Tests'
    inputs:
      command: test
      projects: '**/*UnitTests/*.csproj'
      arguments: '--configuration $(buildConfiguration)'

I had the same issue and spent ages trying out different file matching patterns, .NET Core versions, etc.

My build pipeline was publishing the tests to the artifacts directory, which you can conveniently do with a publish command. But my testing agent was not downloading the artifacts and that was the problem. I was using different agents for deployment and for testing so I didn't notice that something was wrong because the deployment agent had access to the resources but the test agent didn't.

Make sure you've selected to download the artifacts in the Artifact Download section of the agent configuration tab. It's all the way down and I think by default it showed my build package, making me think that it is being downloaded. But I still had to expand it and tick the 'select all artifacts' option. If it's configured fine, you should have a 'Download artifact' task in your deployment logs.

My build pipeline's publish task:

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/*ServiceTests.csproj'
    arguments: '-c $(buildConfiguration) -o $(Build.ArtifactStagingDirectory)/servicetests'
    modifyOutputPath: false
    zipAfterPublish: false

My test agent Artifact Download section: enter image description here

My test task's selection config: enter image description here

Related