1
votes

I have the following azure-pipeline to run two docker compose tasks for 2 unit test projects.

    - task: DockerCompose@0

      displayName: 'Run Application Unit Tests'

      inputs:

        containerregistrytype: 'Azure Container Registry'

        azureSubscription: $(azureSubscription)

        azureContainerRegistry: $(azureContainerRegistry)

        dockerComposeFile: '**/docker-compose.yml'

        action: 'Run a specific service'

        serviceName: 'application.tests'

        detached: false



    - task: DockerCompose@0

      displayName: 'Run Infrastructure Unit Tests'

      inputs:

        containerregistrytype: 'Azure Container Registry'

        azureSubscription: $(azureSubscription)

        azureContainerRegistry: $(azureContainerRegistry)

        dockerComposeFile: '**/docker-compose.yml'

        action: 'Run a specific service'

        serviceName: 'infrastructure.tests'

        detached: false



    - task: PublishTestResults@2

      displayName: 'Publish test results'

      inputs:

        testResultsFormat: 'VSTest'

        testResultsFiles: '/opt/vsts/work/_temp/*.trx'

        mergeTestResults: true

        failTaskOnFailedTests: true



    - task: PublishCodeCoverageResults@1

      displayName: 'Publish coverage report'

      inputs:

        codeCoverageTool: Cobertura

        summaryFileLocation: '/opt/vsts/work/_temp/*.cobertura.xml' 

This works fine, and combines the test and code coverage results. But I have to define each unit test project in the pipeline in a separate task.

Is there a way to run the tests for all projects in a single azure-pipeline task?

Both projects are in the same solution (.NET Core). I understand I could have the tests in a single project, but wanted to keep a separation of concerns.

1
Not get your latest information, is the workaround helpful for you? Or if you have any concern, feel free to share it here.Hugh Lin
Thank you Hugh. I will give this a try, and will mark your answer as accepted when I get it working.Stephen Raman

1 Answers

2
votes

If you configure multiple services in the compose file, you can try to use Run service images action.

enter image description here