Creating a Diagnostic Data Adapter to Collect Custom Data or Affect a Test Machine

You might want to create your own diagnostic data adapter to collect data when you run a test, or you might want to affect the test machine as part of your test. For example, you might want to collect log files that are created by your application under test and attach them to your test results, or you might want to run your tests when there is limited disk space left on your computer. Using APIs provided within Visual Studio Premium, you can write code to perform tasks at specific points in your test run. For example, you can perform tasks when a test run starts, before and after each individual test is run, and when the test run finishes.

You can provide default input to your custom diagnostic data adapter using a configuration settings file. For example, you can provide information about the location of the file you want to collect and attach to your test results, or how much disk space you want to be left on the system. This data can be configured for each test settings that you create. It can be displayed and edited using the default editor provided with Microsoft Test Manager or you can create your own user control to use as an editor. Any changes that are made to the adapter configuration in your editor are stored with your test settings.

If you are running your tests from Microsoft Test Manager, you can associate the test settings with your test plan. If you are running your tests from Visual Studio, you must set these test settings to be active. For more information about test settings, see Setting Up Machines and Collecting Diagnostic Information Using Test Settings.

Tasks

Use the following topics to help you create Diagnostic Data Adapters:

Tasks

Associated Topics

Creating a Diagnostic Data Adapter: You create a diagnostic data adapter by creating a class library, and then use the diagnostic data adapter APIs to collect information that you want or impact a test system that you are using to run your tests.

Installing a Custom Diagnostic Data Adapter: You can install your diagnostic data adapter, or an adapter provided by someone else, by copying it into the correct directory.

Selecting a Custom Diagnostic Data Adapter to Use When Tests are Run: You can select which diagnostic data adapter to use for your test settings, so that the adapter is used when you run your tests.

Configuring what a Diagnostic Data Adapter does: You can configure the settings to control the actions of the diagnostic data adapter in that specific test settings.

To see sample code for making a simple diagnostic data adapter that collects a file and a custom editor for the adapter, see Sample Project for Creating a Diagnostic Data Adapter.

To see sample code that enables you to call Process Monitor while running a test and return the collected log back to the test to be uploaded to the results, see the following Microsoft Web site.

External resources

Guidance

Testing for Continuous Delivery with Visual Studio 2012 – Chapter 6: A Testing Toolbox

See Also

Tasks

Sample Project for Creating a Diagnostic Data Adapter

Concepts

Setting Up Machines and Collecting Diagnostic Information Using Test Settings