Finding theTests that are Affected by Code Changes

09/11/2012

4 minutes to read

In this article

You can use Microsoft Test Manager to help you determine which tests might have to be run, based on coding changes that were made to the application you are testing. To be able to use this functionality, you have to use Team Foundation Build to build your application and use Visual Studio for version control for your source code.

This functionality to determine which tests might have to be run, based on coding changes, is only supported for applications developed using managed code.

To find the recommended tests, you must first run your manual tests using Test Runner or run your automated tests. When you run these tests, you have to use test settings that collect the test impact data. This test impact data contains information about which methods are called when you run your tests. These links between methods in your application and test cases are stored to determine which test cases should be recommended to run again based on changes to the methods.

Test impact data is only collected when tests run and pass. This creates a baseline to gather valid data for which methods are used when the full test is run. When a test fails, only partial data of the methods that were used to run the test could be collected. This partial data would be inaccurate.

When a new build is created, any changes that were made to methods since a previous build and checked in using version control are compared with the test impact data. If you view the details of a specific build, you can see any impacted tests. For example, if a bug is fixed that updates a specific method, you can then compare the builds to find the recommended test cases as shown in the following illustration.

Note

Only test cases are displayed here. Automated tests that are not associated with test cases are not displayed in the Recommended Tests activity. For example, to view unit tests that might be impacted by a new build that are not associated with a test case, you can open the details for the specific build from Visual Studio.

To find which test cases are affected by code changes

Open your Test Plan in Microsoft Test Manager. For more information see System Testing with MTM.

Configure test settings to collect test impact data

The default settings collect test impact data for the local machine on which you are running the tests, but not for other machines. For example if you are testing a web server and you want to find the tests that are affected by changes in the server code, then you must configure the test settings so that test impact data is collected from the server role.

The test impact data will be attached to your test results with a file name extension of testimpact.xml. Only test impact data for tests that pass is saved. You must start any processes for the application after you start the first test in your test run.