Visual Studio 2017 | Visual Studio 2015 | VSTS | TFS 2017 | TFS 2015
Make sure that your app still works after every check-in and build using Visual Studio Team Services (VSTS) or Team Foundation Server (TFS). Find problems earlier by running tests automatically with each build. When your build is done, review your test results to start resolving the problems that you find.
This quickstart shows how to run unit tests with your build for .NET and ASP.NET apps. It uses the Visual Studio Test task.
Before you start
- Check in your solution to VSTS. Include your test projects.
Create a build definition
Your build definition must include a test task that runs unit tests. For example, if you're building a Visual Studio solution in VSTS, your build definition should include a Visual Studio Test task. After your build starts, this task automatically runs all the unit tests in your solution - on the same build machine.
If your build definition does not contain a test task, add one to it.

Edit the Visual Studio Test task. You can add filter criteria to run specific tests, enable code coverage, run tests from other unit test frameworks, and so on.

For information about the option settings of the Visual Studio Test task, see:
The Visual Studio Test task version 2 supports Test Impact Analysis (TIA). See these blog posts.
When you're done, save your build definition.

Start the build
Start the build by adding it to the build queue.
After the build finishes, you can review the test results to resolve any problems that happened. Go to the build to open the build summary.

Review the results
Open the test run results summary and compare your test results between this build and the last build. Here you'll find changes in new, failed, and passed tests, how long these tests took to run, how long these tests have been failing, and more. Organize your test results and open bugs directly for failed tests.

To start debugging a failed test, open the test and review the resulting error and stack trace.
