How to calculate code coverage in .NET and integrate into Azure DevOps

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ค. 2024
  • Support my channel on Patreon platform: / artemgrabovski
    Hi! I’m Artem Grabovski and today we will discuss how you could efficiently use code coverage tools in .NET and integrate them into Azure DevOps.
    In this video we will discuss the following questions:
    - Which open source library you could use to calculate code coverage in .NET?
    - How to visualize code coverage reports?
    - How to integrate code coverage into YAML build pipelines in Azure DevOps?
    - How to control advanced settings for code coverage tools?
    0:00 Introduction to code coverage.
    1:26 Demo. Integrate code coverage into project.
    4:50 Demo. Visualize Coverlet report using Report Generator.
    7:27 Demo. Integrate code coverage into YAML build pipelines in Azure DevOps.
    Coverlet: github.com/coverlet-coverage/...
    Report generator: github.com/danielpalme/Report...
    My personal book recommendation about unit-tests: amzn.to/3LuqJTl
    Plainzer, free dividend tracker app: plainzer.com
    My setup for TH-cam videos:
    - Microphone. Elgato Wave 3: amzn.to/3nitJc6
    - Camera. Anker PowerConf C200: amzn.to/44fXqLz
    Follow me:
    - LinkedIn: / artemgrabovski
    - Instagram: / artemgrabovski
    #dotnet #csharp #codecoverage #coverlet #unittesting #azuredevops
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 19

  • @sivaramkumar_perumal
    @sivaramkumar_perumal 20 วันที่ผ่านมา


    I got to know today by this videos.. test and code coverage are difference and relation. Thank 😮😊

  • @user-xo9jq1jm9h
    @user-xo9jq1jm9h ปีที่แล้ว +2

    Very interesting, explains it very well!

  • @praleska-eu
    @praleska-eu ปีที่แล้ว +1

    Nicely done Artem! There is something you probably could consider for the next video: on real projects, there are many assemblies with the Unit Tests. The approach you demonstrated will just grab the firstly found cobertura report found while you'll have many of them, for each assembly. So, if you want it to work properly, I believe, you need to combine the reports prior to publishing the report results.

    • @artemgrabovski
      @artemgrabovski  ปีที่แล้ว +2

      Thanks, Sergey! I really appreciate your feedback! You’ve mentioned problem which is actual for real projects. There are multiple ways how to resolve this one.
      Solution 1. Resolve on ReportGenerator level (without integration into Azure DevOps)
      ReportGenerator supports HTML report generation based on multiple cobertura files.
      Additional information: github.com/danielpalme/ReportGenerator/issues/282
      Solution 2. Resolve on Azure DevOps level (under the hood it’s using ReportGenerator)
      New version of “Publish Code Coverage Results” build task supports multiple report files. At the same time, for some reasons this build task still depends on old .NET Core SDK.
      Additional information: learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/publish-code-coverage-results-v2?view=azure-pipelines
      I will take into consideration these problems in the next videos!

  • @yashraj6727
    @yashraj6727 7 หลายเดือนก่อน

    Good work.. Thank You

  • @ukrnets
    @ukrnets ปีที่แล้ว +1

    Thanks for this useful comment. I will try to apply it in my project

    • @artemgrabovski
      @artemgrabovski  ปีที่แล้ว

      Good luck! If you have any additional questions, just let me know

  • @claireclaire633
    @claireclaire633 ปีที่แล้ว +2

    Great! Thanks

  • @krishnabhutda7732
    @krishnabhutda7732 11 หลายเดือนก่อน +1

    Nice explanation!
    Thank you!!!

    • @artemgrabovski
      @artemgrabovski  11 หลายเดือนก่อน

      Glad it was helpful!

  • @pigrebanto
    @pigrebanto 4 หลายเดือนก่อน

    thanks. Can you force failure in the pipeline if the the threashold is not achieved?

  • @anment
    @anment 10 หลายเดือนก่อน +1

    Very nice explanation
    But I have one question, How can I create a dashboard for all pipelines? For example, if I have two repo and both have their own code coverage, but I want to create one dashboard that shows all the metrics that I have in both pipelines

    • @artemgrabovski
      @artemgrabovski  9 หลายเดือนก่อน

      Thanks a lot! Unfortunately Azure DevOps doesn't support dashboard with code coverage for all pipelines. At the same time you could use SonarQube for these purposes (www.sonarsource.com/products/sonarqube). It will provide you a page with list of services and information about code coverage for each of them.

  • @BadmintonBoss
    @BadmintonBoss ปีที่แล้ว +1

    Very nicely explained.
    One question (may be a silly one).
    It can be configured on any kind of unit tests, right (you used XUnit)? I mean it can be configured on NUnit and MSTests too?
    It is not dependent on the unit testing framework, right?

    • @artemgrabovski
      @artemgrabovski  ปีที่แล้ว +2

      You are totally correct, it doesn’t depend on some specific test framework