Get started with continuous testing

Last Update: 7/3/2017

Team Services | TFS 2017 | TFS 2015 | Previous version

Make sure that your app still works after every check-in and build using Visual Studio Team Services. 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.

In this example, you'll learn how to:

Before you start

This overview shows how to get started by running unit tests with your build.

  1. Check in your solution to Visual Studio Team Services. Include your test projects.

  2. Create a build definition that builds your solution after each check-in, using continuous integration.

When you're ready to run other continuous tests, such as system tests, under more realistic conditions, create environments from physical or virtual machines that you've already set up. Then set up your build to run your app and tests in the environments that you created.

You can create and use a test lab instead of using Team Services or Team Foundation Server. For more information, see Use a lab environment for your devops

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 Team Services, 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.

  1. If your build definition does not contain a test task, add one to it.

    Add a VS Test task

  2. 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 Run Tests using Visual Studio task.

    Build definition: customize unit test run

    The Visual Studio Test task version 2 supports Test Impact Analysis (TIA). See these blog posts.

  3. When you're done, save your build definition.

    Build definition: save

Start the build

  1. Start the build by adding it to the build queue.

    Build definition: queue build

  2. 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.

    Go to Build hub, build definition, build summary

Review the results

  1. 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.

    Compare test result summaries between builds

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

    Error and stack trace for a failed test

Next steps

See also

Also see the blog posts and videos listed in the References section.

Help and support

Submit bugs through Connect, and make suggestions on Uservoice. We look forward to your feedback.