C# unit testing best practices for excellent code coverage

C# unit testing best practices for excellent code coverage

HomeMilan JovanovićC# unit testing best practices for excellent code coverage
C# unit testing best practices for excellent code coverage
ChannelPublish DateThumbnail & View CountDownload Video
Channel AvatarPublish Date not found Thumbnail
0 Views
️ Master the modular monolith architecture: https://bit.ly/3SXlzSt
Accelerate your Clean Architecture knowledge: https://bit.ly/3PupkOJ
Support me on Patreon to access the source code: https://www.patreon.com/milanjovanovic

In this video, I'll show you how to unit test domain services. Unit testing domain services is easy because most dependencies are injected as interfaces. We'll use NSubstitute to provide mockups during unit testing and use FluentAssertion to verify that our services behaved as expected. I'll also discuss code coverage and explain why you shouldn't focus on this particular metric. Instead, focus on writing high-quality unit tests.

Subscribe to my weekly .NET newsletter:
https://www.milanjovanovic.tech

Read my blog here:
https://www.milanjovanovic.tech/blog

Chapter
0:00 What will we test?
1:08 Implementation of the first test case
4:10 Improving the test class setup
5:50 Implementation of the second test case
7:11 Simulate external dependencies with NSubstitute
11:09 Writing the test case for the Happy Path
12:47 How to check method calls on your mock with NSubstitute
15:50 Code Coverage Report – just focus on writing good unit tests

Please take the opportunity to connect with your friends and family and share this video with them if you find it useful.