Tests in action
Until now, we have discussed test strategies and various types of microservice tests. We've also discussed how to test and what to test. In this section, we will see tests in action; we will implement tests with the use of:
- Visual Studio 2017 RC or later
- .NET Core
- ASP.NET Core API
- xUnit and MS tests
- The Moq framework
Getting ready with the test project
We will test our microservice application: FlixOne bookstore. With the help of code examples, we will see how to perform unit tests, stubbing, and mocking.
Note
We created the FlixOne bookstore application in Chapter 2, Building Microservices.
Before we start writing tests, we should set up a test project in our existing application. There are a few simple steps we can take with this test project setup:
- Using Visual Studio, add a new .NET Core (class library) project to your existing solution
- You can alternatively use the
cli
command to add the new project--open the bash command or the Visual Studio command prompt and executedotnet...