Run tests

Let's take the same application we created in the previous section for unit tests:

  1. Add a new project for integration tests, and make sure the project structure looks like the following screenshot:
  1. Write the following code in the constructor of ProductTest.cs:
var server = new TestServer(  new WebHostBuilder()  .UseStartup<TestStartup>());_client = server.CreateClient();

In the preceding code block, we initialized TestServer , where we used TestStartup as our startup entry file. Finally, we created a private readonly HttpClient _client; of our WebHostBuilder().

  1. Then, write a simple method that calls the productlist resource:

Get Building RESTful Web Services with .NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.