Testing Web APIs
Once we have our APIs designed and created, we need a way to test them in our IDE and our integration tests. Luckily, Visual Studio has added the new Endpoints Explorer.
In this section, we’ll learn two ways to test our APIs. One way is through our development environment using Visual Studio. The second way we’ll test our API is through integration tests. If we have a CI/CD pipeline (which we should from Chapter 2), these will automatically run to confirm our APIs work as expected.
Visual Studio Endpoints Explorer
Historically, developers using Visual Studio had to run a separate tool to test their APIs, but with the latest version of .NET 8, the Visual Studio team added a new panel called Endpoints Explorer:
Figure 9.4 – Endpoints Explorer
If we have a collection of APIs defined in the Program.cs
file, our collection will appear as follows:
Figure 9.5 – Collection of APIs...