This documentation is archived and is not being maintained.

How to: Create a Coded Web Test

A coded Web test is typically created by converting an existing, recorded Web test into a coded Web test. A recorded Web test begins as a tree of requests that are visible in the Web Test Editor. A coded Web test is a .NET class that generates a sequence of WebTestRequests. It can be programmed using either C# or Visual Basic. A coded Web test can be created manually, but it is suggested practice to convert a recorded Web test to a coded Web test.

After a Web test has been converted from recorded to coded, you can edit that code like any other source code. Additionally, you can add looping and branching constructs, dynamically change the number of requests in the test, and dynamically generate the set of URLs that the test hits.

NoteNote

For more information about the API for the Web testing tools, see How to: Use the Web Test API.

Coded Web tests are launched from either the Test View or Test Manager window. You can use coded Web tests in load tests. For more information about load tests, see Creating Load Tests.

NoteTip

If you want to use data binding or any one of the plug-ins in your coded Web tests, it is a good practice to add them before generating the coded test. This is because it is easier to have Team Edition for Testers generate the data-binding code than to write it yourself.

To convert a recorded Web test

  1. Open a solution that contains a recorded Web test.

    For more information, see How to: Record a Web Test.

  2. Open the Web test file.

  3. Click the Generate Code button on the toolbar in the Web Test Editor.

    You are prompted for a name for the coded Web test.

  4. Type an appropriate name in the dialog box for the coded Web test class that is generated, and then click OK.

  5. Click Build, and then click Build Solution from the menu.

    Your code compiles.

To run a coded Web test

  1. On the Test menu, click Windows and then click Test View.

  2. Right-click your coded Web test and select Run Selection.

  3. Click OK to run your test. The test runs immediately.

    In the Test Results window, the test result is displayed as In Progress until your test completes running. At this point, Passed or Failed is displayed. It displays Failed if the test throws an exception or if a validation/extraction rule fails.

NoteNote

The progress of a coded Web test can be viewed just like a recorded Web test. Double-clicking the coded Web test in the Test Results window displays the Test Viewer.

See Also

Show: