How to collect the code coverage of your tests in .NET

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ส.ค. 2021
  • Become a Patreon and get source code access: / nickchapsas
    Check out my courses: dometrain.com
    Hello everybody I'm Nick and in this video I am going to show you how you can easily collect the code coverage of your .NET application both in a quick and easy way but also in a more details view. Code coverage sometimes is a requirement for your projects and in this video I will show you how you can collect it without relying on Visual Studio or Rider.
    Give Coverlet a star: github.com/coverlet-coverage/...
    Give ReportGenerator a star: github.com/danielpalme/Report...
    Don't forget to comment, like and subscribe :)
    Social Media:
    Follow me on GitHub: bit.ly/ChapsasGitHub
    Follow me on Twitter: bit.ly/ChapsasTwitter
    Connect on LinkedIn: bit.ly/ChapsasLinkedIn
    Keep coding merch: keepcoding.shop
    #codecoverage #dotnet #csharp

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

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

    Fine Code Coverage is a great extension for visual studio for showing the coverlet in the actual ide.

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

      Agree; have been using it for a long time and it's a great addition to VS.

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

    That's so cool, this way you can just host the coverage online somewhere and let your CI update it, and the entire testing team can easily see what tests need to be implemented.

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

    one of the most important theme in real work IMHO. Thx)

  • @felgedits
    @felgedits 3 หลายเดือนก่อน

    Thanks! This really helped with integrating a nice code coverage report to my build.

  • @diale13
    @diale13 2 ปีที่แล้ว

    Loved the video!

  • @AntonioMSpb
    @AntonioMSpb 5 หลายเดือนก่อน

    Thank you, it was useful 👍

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

    Hi Nick, thanks for the great tutorial!
    if we want to exclude multiple files on the collecting XPlat code coverage so that it does not show in the report generator, how do we do this?

  • @sri3884
    @sri3884 3 หลายเดือนก่อน

    Hi , thanks a lot , it really helpful.

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

    excellent

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

    Hi Nick. Are you going to do a video on Microsoft's native Code Coverage in the near future?

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

    This is a great way to visualize the coverage. I am trying to find a way to have it autogenerate some of this for me so I don't have to manually type the commands each time. It looks like a .runsettings configuration could be the way, but I haven't figured out how to do it. Could we do this automatically with a configuration setup?

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

    Excelent video, thank you! But could you please prompt how can I collect the code coverage of all my tests at the same time if I have more than one In my project?

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

    is this useful to get the code coverage after Run Automated Tests? if isn't, do you know any other tool to do so.?

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

    Thanks for helping us through this great tutorial. Could you make a video on how to import a coverage.xml file in SonarQube ? Please pick my question

  • @sagarfulari2765
    @sagarfulari2765 2 ปีที่แล้ว

    Instead of line coverage and branch coverage... Can I generate block coverage report.. Please reply

  • @andrenunes4032
    @andrenunes4032 10 หลายเดือนก่อน

    nice!

  • @matrixlukan
    @matrixlukan 2 ปีที่แล้ว

    Can you please make a video on ABP framework?

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

    If you have multiple dlls, that would generate multiple reports - how would you merge them all?

  • @ronaldoperes1202
    @ronaldoperes1202 2 ปีที่แล้ว

    That is very good,
    Can you tell me how can I collect the code coverage of a project with Specflow that do the BDD to do the integration tests?

    • @thespicycoder5583
      @thespicycoder5583 2 ปีที่แล้ว

      If you are using webapplicationfactory in your integration test project, same approach Nick shown should work. Irrespective of you use specflow or not, it should still work.

  • @Yoko-0x0
    @Yoko-0x0 2 ปีที่แล้ว

    Thanks for the video, it helped me a lot. question out of context. what webcam do you use?

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

      I use a Sony ZV-1 with a Camlink 4k

    • @Yoko-0x0
      @Yoko-0x0 2 ปีที่แล้ว

      @@nickchapsas thanks

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

    How is the Total % is different from Average % when coverage is generated via command line?

  • @philc8544
    @philc8544 2 ปีที่แล้ว

    Does this work for .net framework Nick?

  • @rahulchaurasia5560
    @rahulchaurasia5560 6 หลายเดือนก่อน

    Hey nick, I have a question here, I can't see anywhere the Unit tests count, I need to show this in Sonar Dashboards, but whatever the report is being generated, I can't see the unit tests count

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

    anyone know how to exclude the views folder?

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

    Where did you choose for your vacation? It's obvious that you're sunbathing on your face :) Nice video. Keep coding.

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

      Hahaha, is it that obvious?? I was back home in Greece for a couple of weeks :D

    • @ilkerayti
      @ilkerayti 2 ปีที่แล้ว

      @@nickchapsas Ahaha I am from Turkey and live in Izmir that is very close to Greece. Since I am also very white, it is immediately evident on my face at the slightest holiday :))

  • @user-qf2xk1fg6e
    @user-qf2xk1fg6e 11 หลายเดือนก่อน

    What if I have several projects with tests?

  • @arthursoares610
    @arthursoares610 2 ปีที่แล้ว

    Hi Nick. I would like to use your video about MediatR and CQRS as part of software engineering onboarding at my company.
    But we are allocated in Brazil and not every engineer speak English very well.
    Could you please enable subtitles editing on your videos? I'll add the translations by my self.
    Thanks a lot!!!

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

    Why don't you make some video on Unit Testing. There's a lot of people that simply ignore them

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

      I already have one on TDD

  •  2 ปีที่แล้ว +1

    I think Visual Studio is better than Rider at this point. Visual studio allows us to navigate the code, see which statements (not lines) are covered. It's build-in and we don't have to install any library or tool. However, it's available only on the Enterprise version.

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

      VS Enterprise is $250 a month and commercial license for Rider is $349 a YEAR. So not really comparable.

    •  2 ปีที่แล้ว

      @@Zikakoo I didn't say everyone should use Visual Studio instead of Rider because of this idea or do an advertisement for Visual Studio. This is just a comparison for a single feature and everyone should agree that Visual Studio is better than Rider in some points and Rider is better in some other points. I'm using and happy with both.

    •  2 ปีที่แล้ว +1

      @@Zikakoo One other thing is when you pay 349 per year, what you have it the license for Rider. That's all. When you pay 250$ per month for VS Enterprise, you have a service and you have benefited from Windows (xp, vista, 7, 10) licenses, Office (plus version, not 365) license, 150$ Azure monthly credits, Pluralsight and a lot more benifit. I can't list them all in a short comment. So, comparing 250$ per month and 349 per year as you did is NOT fair. Anyway, I didn't intend to recommend anyone to use Visual Studio instead of Rider.

    •  2 ปีที่แล้ว

      Hopefully JetBrains folks going to implement something similar soon.

    • @Assgier
      @Assgier 2 ปีที่แล้ว

      @ They should start by attempting to speed up ReSharper first, or at least have it not hang up VS completely while it's initializing. Even in VS 2022 (which is already faster on itself, compared to VS 2019) ReSharper slows down starting up VS and loading solutions tremendously. Luckily for them having it available is still preferred by us over the speed gained in VS by removing it.

  • @victorgarcia3526
    @victorgarcia3526 2 ปีที่แล้ว

    So this all was just to flex on us about his ridr license