Closed sdg002 closed 4 years ago
Hi @sdg002,
did you publish code coverage data in your pipeline? How are you creating the coverage data? Are you using the Visual Studio Test task or another task?
René
Hi @ReneSchumacher Thanks for the quick response. We are using MSTEST. Here is a snapshot from our YML.
- script: |
dotnet test --logger "trx;LogFileName=Test-Results.trx" "$(System.DefaultWorkingDirectory)/CorResilience.Ingestion.Garmin.Api.Tests" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/coverage1.cobertura.xml
displayName: Run Unit Tests
- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '**/Test-*.trx'
searchFolder: '$(System.DefaultWorkingDirectory)/'
- task: reportgenerator@4
displayName: ReportGenerator
inputs:
reports: '$(Build.SourcesDirectory)/TestResults/Coverage/*.xml'
targetdir: '$(Build.SourcesDirectory)/TestResults/Coverage'
sourcedirs: '$(Build.SourcesDirectory)'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage results'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/TestResults/Coverage/*cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)/TestResults/Coverage'
- task: BuildQualityChecks@6
inputs:
checkCoverage: true
coverageFailOption: 'fixed'
coverageType: 'lines'
coverageThreshold: '80'
- task: DotNetCoreCLI@2
inputs:
command: publish
arguments: '--configuration Release /p:Version=$(MajorVersion).$(MinorVersion).$(PatchNumber) /p:FileVersion=$(Build.BuildNumber) --output publish_output'
projects: "$(System.DefaultWorkingDirectory)/CorResilience.Ingestion.Garmin.Api/*.csproj"
publishWebProjects: false
modifyOutputPath: true
zipAfterPublish: false
displayName: Publish Function App
Screen capture
Can you make sure that you see code coverage values in the build summary? And/or could you post the log of the PublishCodeCoverageResult task?
8_Publish code coverage results.zip
The log from the PublishCodeCoverageResult attached.
Please, could you guide me as to how I can access the actual code coverage results from this step?
Thank you.
Cobertura.zip The code coverage file attached. Nearly empty!
Code Coverage Report_5086.zip The complete ZIP from Azure Devops. Empty!
Looks like there is a problem with the generation of the Code Coverage report.
This is from the Run Unit Tests log file
2020-05-27T18:24:24.6588918Z D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved.
2020-05-27T18:24:24.6592270Z D:\a\1\s\CorResilience.Ingestion.Garmin.Api\CorResilience.Ingestion.Garmin.Api.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved. [D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj]
2020-05-27T18:24:25.8321535Z D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved.
2020-05-27T18:24:26.7202218Z D:\a\1\s\CorResilience.Ingestion.Garmin.Api\CorResilience.Ingestion.Garmin.Api.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved.
2020-05-27T18:24:31.0574189Z C:\Users\VssAdministrator\.nuget\packages\coverlet.msbuild\2.6.3\build\coverlet.msbuild.targets(24,5): warning : [coverlet] Unable to instrument module: D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\bin\Debug\netcoreapp2.1\CorResilience.Ingestion.Garmin.Api.dll because : The type initializer for 'Coverlet.Core.Instrumentation.NetstandardAwareAssemblyResolver' threw an exception. [D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj]
2020-05-27T18:24:31.0641352Z C:\Users\VssAdministrator\.nuget\packages\coverlet.msbuild\2.6.3\build\coverlet.msbuild.targets(24,5): warning : [coverlet] Unable to instrument module: D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\bin\Debug\netcoreapp2.1\CorResilience.Ingestion.Garmin.Core.dll because : The type initializer for 'Coverlet.Core.Instrumentation.NetstandardAwareAssemblyResolver' threw an exception. [D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj]
2020-05-27T18:24:31.0684045Z C:\Users\VssAdministrator\.nuget\packages\coverlet.msbuild\2.6.3\build\coverlet.msbuild.targets(24,5): warning : [coverlet] Unable to instrument module: D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\bin\Debug\netcoreapp2.1\CorResilience.Ingestion.Garmin.Infrastructure.dll because : The type initializer for 'Coverlet.Core.Instrumentation.NetstandardAwareAssemblyResolver' threw an exception. [D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj]
2020-05-27T18:24:31.4220600Z Test run for D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\bin\Debug\netcoreapp2.1\CorResilience.Ingestion.Garmin.Api.Tests.dll(.NETCoreApp,Version=v2.1)
Problem solved. Updated NUGET reference and code coverage information was generated correctly.
PackageReference Include="coverlet.msbuild" Version="2.8.1"
Thank you.
Great that you could resolve the issue and thanks for letting us know. I'm closing the issue now but please feel free to open a new one if you run into any other problems with t he task.
Snapshot of from the log
{"id":"5083","url":"https://dev.azure.com/CorResilience/_apis/build/Builds/5083"},"deltaBuild":null} 2020-05-27T17:40:31.8975676Z ##[debug]------------------ END RAW DATA ------------------ 2020-05-27T17:40:31.8975885Z Waiting for code coverage data... 2020-05-27T17:40:34.2431324Z ##[debug]-------------------- RAW DATA -------------------- 2020-05-27T17:40:34.2432371Z ##[debug]buildCoverageSummary: 2020-05-27T17:40:34.2433094Z ##[debug]{"coverageData":[],"build":{"id":"5083","url":"https://dev.azure.com/CorResilience/_apis/build/Builds/5083"},"deltaBuild":null} 2020-05-27T17:40:34.2434308Z ##[debug]------------------ END RAW DATA ------------------ 2020-05-27T17:40:34.2434726Z Waiting for code coverage data... 2020-05-27T17:40:36.5810992Z ##[debug]-------------------- RAW DATA -------------------- 2020-05-27T17:40:36.5811648Z ##[debug]buildCoverageSummary: 2020-05-27T17:40:36.5812057Z ##[debug]{"coverageData":[],"build":{"id":"5083","url":"https://dev.azure.com/CorResilience/_apis/build/Builds/5083"},"deltaBuild":null} 2020-05-27T17:40:36.5812506Z ##[debug]------------------ END RAW DATA ------------------ 2020-05-27T17:40:36.5812712Z Waiting for code coverage data... 2020-05-27T17:40:37.4370691Z ##[error]The task has timed out. 2020-05-27T17:40:37.4373265Z ##[section]Finishing: Check build quality
YAML Task