Поделиться через


How to: Create a Coded Web Performance Test

This topic applies to:

Visual Studio Ultimate

Visual Studio Premium

Visual Studio Professional 

Visual Studio Express

Topic applies Topic does not apply Topic does not apply Topic does not apply

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

After a Web performance 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.

Note

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

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

Tip

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

To convert a recorded Web performance test

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

    For more information, see How to: Create a New Web Performance Test Using the Web Performance Test Recorder.

  2. Open the Web performance test file.

    Tip

    You can use the Web performance test that is created in the following two walkthroughs to create a coded Web test: Walkthrough: Creating a Simple Web Application and Walkthrough: Recording and Running a Web Performance Test.

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

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

  4. Type an appropriate name in the dialog box for the coded Web performance 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 performance test

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

  2. Right-click your coded Web performance 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.

    Note

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

See Also

Tasks

Walkthrough: Creating a Coded Web Performance Test

How to: Use the Web Performance Test API

How to: Create a New Web Performance Test Using the Web Performance Test Recorder

Other Resources

Creating and Editing Web Performance Tests