liveBook · Manning

Dotnet test

As explained in ASP.NET Core in Action, 3e

dotnet test is a .NET CLI command that restores and builds a test project and then runs its tests.

dotnet test runs the tests in a .NET test project using the .NET SDK, regardless of whether the project uses xUnit, NUnit, MSTest, or another compatible framework. section 35.1

Running the command follows a predictable sequence:

  • Run dotnet test from a test-project folder to restore dependencies, build the project, and execute its tests. section 35.3
  • Run it from a solution folder to execute all test projects referenced by the solution file. section 35.3
  • Use the same .NET SDK infrastructure as Visual Studio's test runner, producing equivalent results. section 35.1 section 35.3

Run a test project

From the unit-test project's folder, run dotnet test. The command restores and builds the test project, then reports the results of its tests. section 35.3

Figure 35.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.
CH35_F03_Lock3

A command-line figure shows dotnet test restoring and building a test project before executing its tests. section 35.3

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains project scope, restore and build behavior, and test-runner integration without detailing individual test implementation.
Examples
Uses a dotnet test command, project-folder and solution-folder execution, and Visual Studio Test Explorer as concrete examples.
What it assumes
Assumes a test project with the .NET Test SDK, a test framework, and a compatible runner adapter.
What you can do after
Operate/configure it to restore, build, and execute tests for a project or solution.
How it connects
Connects the .NET SDK with test projects, test frameworks, runner adapters, Visual Studio, and the VSTest protocol.

Also explained in

Compare how 2 books explain dotnet test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.