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

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

Nick Chapsas

2 года назад

62,667 Просмотров

Become a Patreon and get source code access: https://www.patreon.com/nickchapsas
Check out my courses: https://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: https://github.com/coverlet-coverage/coverlet
Give ReportGenerator a star: https://github.com/danielpalme/ReportGenerator

Don't forget to comment, like and subscribe :)

Social Media:
Follow me on GitHub: http://bit.ly/ChapsasGitHub
Follow me on Twitter: http://bit.ly/ChapsasTwitter
Connect on LinkedIn: http://bit.ly/ChapsasLinkedIn

Keep coding merch: https://keepcoding.shop

#codecoverage #dotnet #csharp

Тэги:

#Elfocrash #elfo #coding #.netcore #dot_net #core #C# #how_to_code #tutorial #development #software_engineering #microsoft #microsoft_mvp #.net_core #nick_chapsas #chapsas #.net #dotnet #code_coverage #code_coverage_testing #code_coverage_.net #coverlet #cobertura #unit_testing #testing #test_coverage
Ссылки и html тэги не поддерживаются


Комментарии:

@rahulchaurasia5560
@rahulchaurasia5560 - 29.12.2023 21:20

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

Ответить
@andrenunes4032
@andrenunes4032 - 03.09.2023 08:57

nice!

Ответить
@user-qf2xk1fg6e
@user-qf2xk1fg6e - 27.07.2023 17:37

What if I have several projects with tests?

Ответить
@bvsjagan
@bvsjagan - 07.06.2023 00:29

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

Ответить
@tejaspatel1679
@tejaspatel1679 - 14.03.2023 02:35

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

Ответить
@th3oth3rjak3
@th3oth3rjak3 - 13.03.2023 03:48

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?

Ответить
@vaddiparthivenkatamuralikr8334
@vaddiparthivenkatamuralikr8334 - 12.11.2022 12:26

excellent

Ответить
@itania2266
@itania2266 - 27.10.2022 18:17

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?

Ответить
@KARIMYacine
@KARIMYacine - 26.08.2022 21:08

anyone know how to exclude the views folder?

Ответить
@subhrajitmazumder7122
@subhrajitmazumder7122 - 30.07.2022 12:52

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

Ответить
@ghostslinger3148
@ghostslinger3148 - 09.05.2022 11:33

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?

Ответить
@Yoko-X
@Yoko-X - 15.03.2022 17:33

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

Ответить
@byrondelgado8165
@byrondelgado8165 - 01.03.2022 21:27

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

Ответить
@ronaldoperes1202
@ronaldoperes1202 - 22.02.2022 15:08

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?

Ответить
@GioacchinoPiazzolla
@GioacchinoPiazzolla - 17.02.2022 13:51

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

Ответить
@barmetler
@barmetler - 02.12.2021 14:48

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.

Ответить
@sagarfulari2765
@sagarfulari2765 - 13.11.2021 14:07

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

Ответить
@diale13
@diale13 - 09.10.2021 17:27

Loved the video!

Ответить
@matteobarbieri2989
@matteobarbieri2989 - 29.08.2021 14:10

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

Ответить
@victorgarcia3526
@victorgarcia3526 - 28.08.2021 11:40

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

Ответить
@arthursoares610
@arthursoares610 - 28.08.2021 04:36

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!!!

Ответить
@yumyumrocks1
@yumyumrocks1 - 27.08.2021 20:17

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

Ответить
@philc8544
@philc8544 - 27.08.2021 18:53

Does this work for .net framework Nick?

Ответить
@matrixlukan
@matrixlukan - 27.08.2021 18:04

Can you please make a video on ABP framework?

Ответить
@ilkerayti
@ilkerayti - 27.08.2021 15:45

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

Ответить
@antonkomyshan1727
@antonkomyshan1727 - 27.08.2021 14:59

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

Ответить
@VoQuangHoa
@VoQuangHoa - 27.08.2021 14:48

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.

Ответить