In this video, I will be doing unit testing for the business layer for an ASP.Net Core Web API application. And I will be using XUnit for the unit testing framework and Moq for mocking framework.
XUnit is an open-source unit testing framework that supports both traditional .Net Framework as well as .Net Core Framework.
Moq is a mocking framework, which helps mock an interface or abstract class. This helps not worrying about the interfaces that are dependencies of a class. But just focusing on the core logic of the class under test.
Unit testing is extremely important for agile development. From my personal experience, it is much easier to do changes in a rapid development environment, if you have better coverage with unit testing. I personally prefer to have good enough tests to give me confidence that I can make changes without worrying about defects. Unit testing adds cost to the overall projects, so you have to make the right balance between your test coverage vs rework cost.
A couple of other popular unit testing frameworks worth mentioning: NUnit, MS Test, MachineSpecs
A popular mocking framework: FakeItEasy
Link to my blog post where I cover in-depth on XUnit and Moq for testing: [ Ссылка ]
.Net Core Unit Testing using XUnit and Moq
Теги
.net coreasp.net core.net core 2.0asp.net core 2.0asp.net web apiasp.net core web apiasp.net core 2.0 web apiweb apiasp.netcxunit.net core xunitmoq.net core moqasp.net core web api moqasp.net core moq.net core xunit moqasp.net core web apu xunit moq.net core 2.0 xunit.net core 2.0 xunit moqunit test .net coreunit test .net