Share via


Walkthrough: Adding Data Binding to a Web Performance Test

In this walkthrough, you will add data binding to a Web performance test and verify that it works correctly.

By using data binding, a database can provide data for a Web performance test. You can bind data from a data source to a part of a Web request that requires data, such as a form post parameter. For more information, see Binding a Data Source to a Web Performance Test

In this walkthrough, you will perform the following tasks:

  • Add data binding to a Web performance test

  • Run the Web performance test to verify that it works correctly

Prerequisites

Here’s what you’ll need:

Preparing for the Walkthrough

For this walkthrough, you will need a sample data source to bind to. You will create a simple database in Microsoft Access.

To prepare the data source

  1. In Microsoft Access create a new blank database. Name the database ColorData.mdb.

    Note

    If you are using Microsoft Access 2007, save the file in Microsoft Office Access 2003 format using the Save As option (*.mdb).

  2. Create a new table that has two fields: ColorID and ColorName.

  3. Save the table and name it Colors.

    Note

    If you are prompted for a primary key, choose No. You do not need a primary key for this walkthrough.

  4. Add the following data to the Colors table:

    ColorID

    ColorName

    0

    Red

    1

    Blue

  5. Close the database.

To prepare the Web performance test

  1. Open the Web application that you created in Walkthrough: Creating a Simple Web App.

  2. Press CTRL+F5 to run the Web application in the browser. You will see the first page. Close the browser.

    Note

    This starts the ASP.NET Development Server that runs the Web application that your Web performance test will test. You will see the ASP.NET Development Server icon in the notification area, at the far right of the taskbar.

  3. Open the Web application that you created in Walkthrough: Recording and Running a Web Performance Test.

  4. In Solution Explorer, double-click ColorWebTest.webtest. The Web Performance Test Editor appears and the list of Web requests is displayed.

Add Data Binding to a Web Performance Test

To add the data source to the Web performance test

  1. In the Web Performance Test Editor, choose the Add Data Source button in the toolbar.

    The New Test Data Source Wizard appears.

  2. In the Data source name box type ColorsMDB.

  3. In the Data source type list choose Database.

  4. Choose Next.

  5. Select an existing connection, or follow these steps:

    1. Choose New Connection.

      The Choose Data Source dialog box appears.

    2. In the Data source list, choose Microsoft Access Database File.

    3. Clear the Always use this selection check box.

    4. Choose Continue.

      The Connection Properties dialog box appears.

    5. In the Database file name box type the file name, or choose Browse and browse to the file. For example, type the following:

      <Your Path>\Data\ColorData.mdb

    6. (Optional) Choose the Test Connection button to verify your connection to the file.

    7. Choose OK to close the Connection Properties dialog box.

    The connection string to access the database is entered in the wizard.

  6. Choose Next.

  7. Under Choose from the available tables for this data source, select the check box next to Colors.

  8. Choose Finish.

    A dialog box appears that prompts you to add the file to your current project.

  9. Choose No.

    A Data Sources node will be added to the Web performance test, and the database appears in the hierarchy.

    For the purposes of this walkthrough, you do not have to add the file to the project. In the future, you can use the following information to help you decide:

    Response

    Result

    Advantage

    Yes

    The file is copied to the project.

    When the project is deployed, there is no extra work that is required.

    No

    The file is not copied to the project. When the project is deployed, you might have to update the path of the file.

    Some data files can be very large, and should be maintained separately from the project. Some data files must be shared among several members of a team, and should be maintained in a central location that all members can access.

  10. On the FILEmenu choose Save ColorWebTest.webtest to save the Web performance test.

To add data binding to the Web performance test

  1. In the Web Performance Test Editor, find the request that redirects to the page Red.aspx. This should be the second node in the request list.

    Important

    The Web application uses a redirect to move from the page Default.aspx to the page Red.aspx. In the Web Performance Test Editor, the request list will show Default.aspx, not Red.aspx, for the request you are trying to find. To find the correct request, expand the request node, expand the Form Post Parameters folder, and confirm that there is an entry RadioButtonList=Red.

  2. Select the RadioButtonList1 node.

  3. In the Properties window, find the Value property. It is currently set to Red because that is what you selected when you recorded the Web performance test. Choose the property, and then choose the down arrow that appears.

  4. Expand ColorsMDB, expand the Colors table, and then select ColorName. The RadioButtonList is now bound to the data source.

  5. In Solution Explorer, choose Local (local.testsettings), open the shortcut menu, and then choose Open.

  6. In the Configure Test Settings dialog box, select Web Test in the left pane, and then select the One run per data source row option in the right pane. This causes the test to run iteratively, one time for each row in the database. On each test iteration, the pointer moves to the next row in the database.

  7. Choose Close. When you are prompted to save changes, choose Yes.

  8. On the FILEmenu choose Save ColorWebTest.webtest to save the Web performance test.

Running the Web Performance Test to Verify that it Works Correctly

To verify the Web performance test

  1. In the Web Performance Test Editor, choose Run Test from the toolbar to start the Web performance test and display the Web Performance Test Results Viewer.

  2. In the Web Performance Test Results Viewer there will be two runs of the Web performance test. Run 1 will use the first row of data, and Run 2 will use the second row of data. Notice that Run 1 visits the page Red.aspx, and Run 2 visits the page Blue.aspx.

    Note

    You might have to scroll up in the Web Performance Test Results Viewer to see both test runs.

    Note

    The error in Run 2 is caused by the response URL validation rule because the URL does not match the one that was recorded. You can remove this validation error by deleting the Response URL validation rule under the Validation Rules node in the Web Performance Test Editor. For more information, see Using Validation and Extraction Rules in Web Performance Tests.

Next Steps

In this walkthrough you added data binding to a Web performance test.

To add validation and extraction rules to your Web performance test, see Walkthrough: Adding Validation and Extraction Rules to a Web Performance Test. Finally, to convert your Web performance test to a coded Web performance test, see Walkthrough: Creating a Coded Web Performance Test.

See Also

Tasks

How to: Add Data Binding to a Web Request

Walkthrough: Creating a Simple Web App

Walkthrough: Recording and Running a Web Performance Test

Walkthrough: Adding Validation and Extraction Rules to a Web Performance Test

Walkthrough: Creating a Coded Web Performance Test

Concepts

Binding a Data Source to a Web Performance Test

Binding a Data Source to a Web Performance Test