All things Tech with a dash of Geek for good measure!

Following on from the previous article, to add Code coverage to nopcommerce when building on Azure-Pipeline as your dev-ops pipeline, it is necessary to add the following nugets to the nopcommerce test projects:

Install Microsoft.CodeCoverage to the 4 test projects:


Install coverlet.collector to the 4 test projects:



It is also necessary to adjust your build pipeline, you can do this using the following in your `azure-pipelines.yml`

name: Azure Pipelines

- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
   command: restore
   projects: ./src/NopCommerce.sln

- task: DotNetCoreCLI@2
displayName: 'dotnet build'
   projects: ./src/NopCommerce.sln
   arguments: '--configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
displayName: 'dotnet test'
   command: test
   projects: |
   arguments: '--configuration $(BuildConfiguration) --collect "XPlat Code coverage"'

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
   codeCoverageTool: Cobertura
   summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'

- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
   command: publish
   arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
   ArtifactName: '$(Parameters.ArtifactName)'

This will allow full code coverage results:


If only SonarCube was also enabled ;-p but we are not the authors, so that is for another tutorial!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Tag Cloud

%d bloggers like this: