concept dotnet test in category asp.net

This is an excerpt from Manning's book ASP.NET Core in Action.
With the .NET Core SDK, testing in ASP.NET Core and .NET Core is now a first-class citizen, on a par with building, restoring packages, and running your application. Just as you can run dotnet build to build a project, or dotnet run to execute it, you can use dotnet test to execute the tests in a test project, regardless of the testing framework used.
The dotnet test command uses the underlying .NET Core SDK to execute the tests for a given project. This is exactly the same as when you run your tests using the Visual Studio test runner, so whichever approach you prefer, the results are the same.
Make sure you run dotnet test from the project folder, which contains the test project’s csproj file. If you try to run it from the solution folder, you’ll get an error that the project can’t be found.
Figure 20.3. You can run tests from the command line using dotnet test. This restores and builds the test project before executing all the tests in the project.
![]()
Calling dotnet test runs a restore and build of your test project and then runs the tests, as you can see from the console output in figure 20.3. Under the hood, the .NET CLI calls into the same underlying infrastructure as Visual Studio does (the .NET Core SDK), so you can use whichever approach better suits your development style.