Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Test Edition
Test Types
Creating a Web Test
 How to: Create a Coded Web Test
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio Team System
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 List Editor window. You can use coded Web tests in load tests. For more information about load tests, see Creating Load Tests.

TipTip:

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 Visual Studio Team System Test Edition 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.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Issues with Coded tests not appearing in Test view      PJBlecha   |   Edit   |   Show History
After clicking "Generate Code" and then building the solution, my coded version (e.g., MyWebTestCoded) does not appear in the Test View window. Consequently, I'm unable to run my coded web test. Is there a line of code that needs to be inserted or deleted, or some other component or class that should be removed (such as ManualTest.mht)?
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker