Quickstart Guide
July 17, 2026 · View on GitHub
This guide gets you running tests from the command line with the Visual Studio Test Platform
(vstest.console.exe). For the exhaustive option list see
command line options.
Which command should I use?
Most people don't run vstest.console.exe directly. Pick the entry point that fits your setup:
| You have… | Use | Notes |
|---|---|---|
| The .NET SDK | dotnet test | Recommended. Builds the project and wraps vstest.console for you. |
| A built test assembly / CI runner | vstest.console.exe <TestFile> | The standalone runner. Does not build; you point it at already-built assemblies. |
Old habit of dotnet vstest | Prefer dotnet test | dotnet vstest is deprecated in favor of dotnet test. |
Getting the standalone runner
vstest.console is not a separate download; it ships inside NuGet packages (and with Visual
Studio). Which package depends on the runtime you need:
- .NET Framework runner (Windows) — the
Microsoft.TestPlatformpackage. After restoring/extracting it the runner lives attools/net462/Common7/IDE/Extensions/TestPlatform/vstest.console.exeand requires .NET Framework. - Cross-platform .NET runner — the
Microsoft.TestPlatform.Portablepackage. It shipsvstest.console.dllundertools/net8.0/, launched withdotnet path/to/vstest.console.dll, and requires a compatible .NET runtime.
When you use dotnet test, the runner and a matching runtime are already provided by the .NET
SDK (pinned by your global.json), so there is nothing extra to install.
Your first run
-
Build a test project (for example an MSTest, xUnit, or NUnit project) so you have a test assembly such as
bin\Debug\net8.0\MyProject.Tests.dll. -
Run the tests:
vstest.console.exe bin\Debug\net8.0\MyProject.Tests.dllOr, to build and run in one step with the SDK:
dotnet test
You can pass more than one assembly and use wildcards:
vstest.console.exe **/bin/Debug/**/*.Tests.dll
The runner prints a per-test summary and a final total. Test results and any collected
artifacts are written under a TestResults directory.
Common tasks
| Task | Command |
|---|---|
| Run a subset of tests | vstest.console.exe Tests.dll /TestCaseFilter:"Priority=1" |
| Produce a TRX report | vstest.console.exe Tests.dll /logger:trx |
| Use a settings file | vstest.console.exe Tests.dll /Settings:test.runsettings |
| Collect code coverage | vstest.console.exe Tests.dll /Collect:"Code Coverage" |
| Run in parallel | vstest.console.exe Tests.dll /Parallel |
| Capture diagnostic logs | vstest.console.exe Tests.dll /Diag:log.txt |
The equivalent dotnet test switches are --filter, --logger, --settings, --collect,
and --diag.
Exit codes
vstest.console.exe returns 0 when the run succeeds and all executed tests pass, and 1
otherwise (test failure, run error, invalid command line, etc.). See
Exit codes for details, including what happens when no tests
match.
Learn more
New to running .NET tests? Start with the official .NET testing documentation:
- Testing in .NET — overview and getting started
- Unit testing with
dotnet test dotnet testcommand referencevstest.console.execommand-line options
Next steps
- Command line options — full option reference
- TestCase filtering
- Configure a test run (.runsettings)
- Passing runsettings from the command line
- Code coverage
- Diagnostics / Troubleshooting
- Environment variables
For test platform internals and extensibility, see the Overview and the RFCs.