Share via


Testing tools in Visual Studio for Mac

Important

Visual Studio for Mac was retired on August 31, 2024 in accordance with Microsoft’s Modern Lifecycle Policy. While you can continue to work with Visual Studio for Mac, there are several other options for developers on Mac such as the preview version of the new C# Dev Kit extension for VS Code.

Learn more about support timelines and alternatives.

Visual Studio for Mac testing tools can help you and your team develop and sustain high standards of code excellence. Unit tests can be written and run using the Microsoft unit test framework (MSTest), xUnit, or NUnit.

Creating tests

To get started with testing, you can create a new test project in your solution by right-clicking your solution and choosing the Add > New Project... menu. Then choose one of the Test categories on the left-side of the dialog (For example, the Web and Console > Tests category). Select the type of test project you want to create, and then select Next. Follow the instructions in the dialogs that appear and then a new test project will be added to your solution.

New project dialog with Web and Console > Tests section selected, showing xUnit, MSTest, and NUnit projects

Note

For more information about unit testing your .NET Core applications and selecting unit test frameworks, see the Unit testing in .NET Core and .NET Standard documentation.

Running tests

The Unit Tests window is used to run unit tests and is opened using the View > Tests menu. Unit tests in your solution are automatically discovered and shown in this window. Here you can run all of the tests or a set of tests that you've selected.

Test Window showing a list of unit tests and a tool bar for running or stopping tests.

When editing a C# class that contains unit tests, you can run tests by right clicking in the test class or a test method and choosing the Run Test(s) or Debug Test(s) menu. Choosing the Run Test(s) menu item will run the tests in the test window, choosing the Debug Test(s) menu will do the same and attach the debugger so you can troubleshoot your code.

Editor right-click menu with Run and Debug Tests options

As tests are running, a Test Results window appears so you can review successful or failed tests, and the output from running those tests.

Test results window showing one failed test and a count of 21 passed tests and 1 failed test.

See also