2

I'm trying to test my .NET Core 5.0 projects in my Azure DevOps pipeline. When using a full path to one of my test projects the pipeline will test that single project. When using a pattern to search for all my test projects he can't find one of them.

My project structure is as follows:

  1. backend
    1. DemoProject (with the .sln file)
      1. DemoProject.Application
      2. DemoProject.Application.Test
      3. DemoProject.Persistance
      4. DemoProject.Persistance.Test
    2. DemoProject 2
      1. ....

To find a solution I created a simple version of my pipeline template:

- master

pool:
  vmImage: ubuntu-latest

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'test'
    projects: './backend/DemoProject/DemoProject.Application.Tests/DemoProject.Application.Tests.csproj'

When using the full path (./backend/DemoProject/DemoProject.Application.Tests/DemoProject.Application.Tests.csproj), the pipeline find's the selected project. When using a pattern (./backend/DemoProject/\*\*/\*.Tests.csproj or ./backend/DemoProject/\*\*/DemoProject.Application.Tests.csproj), the pipeline can't find any project.

Does someone knows what the correct pattern is to run all my test projects inside the DemoProject folder?

eduherminio
  • 1,514
  • 1
  • 15
  • 31
Doodskop
  • 33
  • 6

1 Answers1

2

Try **/*.Test.csproj, I have used it in projects with more complex folder structures without any issues.

    - task: DotNetCoreCLI@2
      inputs:
        command: test
        arguments: --configuration Release
        projects: '**/*.Test.csproj'
        workingDirectory: './backend/DemoProject/'
eduherminio
  • 1,514
  • 1
  • 15
  • 31
  • Besides my demo project I have a second project inside the backend folder. That project I want to test and release separate. With the pattern you suggested both projects will be tested. – Doodskop Mar 16 '21 at 07:31
  • 1
    Could you combine it with [`WorkingDirectory` argument](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devopst) in your task? – eduherminio Mar 16 '21 at 10:23
  • 1
    The combination of the pattern and the WorkingDirectory argument was the solution, thank you! – Doodskop Mar 16 '21 at 12:13
  • 1
    Its an absolute working solution. Worked like charm on a more complex folder structure to run all tests. – Ak777 Jan 31 '23 at 18:41