Walkthrough: Adding Data Binding to a Web Performance Test (CSV File)
In this walkthrough, you will bind a Web performance test to a .CSV file 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:
Visual Studio Ultimate
The Web application that you created in Walkthrough: Creating a Simple Web App
The Web performance test that you created in Walkthrough: Recording and Running a Web Performance Test
Preparing for the Walkthrough
You’ll need a sample data source to bind to, so you’ll create a simple CSV file data source.
To prepare the data source
In Solution Explorer, open the context menu and choose Add and then choose New Folder. Rename the folder Data.
On the Data folder, open the context menu and choose Add and then choose Text File. Name the text file ColorData.csv. Make sure you give the file the .csv extension.
Add the following to the text file:
ColorId, ColorName 0,Red 1,Blue
Save and close the file.
Note
Open the file in Excel and confirm that the data separated by the commas appears in separate columns.
To prepare the Web performance test
Open the Web application that you created in Walkthrough: Creating a Simple Web App.
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 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.
Open the Web application you created in Walkthrough: Recording and Running a Web Performance Test.
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
In the Web Performance Test Editor, choose the Add Data Source button in the toolbar.
The New Test Data Source Wizard appears.
In the Data source name box type ColorsCSV.
In the Data source type list choose CSV File.
Choose Next.
In the Choose a CSV file box, choose the ellipsis to browse to the ColorData.csv file which will be in the Data folder where you project is located.
The data from the CSV file appears in the Preview data pane.
Choose Finish.
A dialog box appears and prompts you to add the file to your current project.
Choose Yes.
A Data Sources node will be added to your Web performance test, and the text file will appear as a table in the hierarchy.
For the purposes of this walkthrough, it is not necessary 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 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 separate 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.
On the FILEmenu choose Save ColorWebTest.webtest to save the Web performance test.
To add data binding to the Web performance test
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.
Select the RadioButtonList1 node.
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.
Expand ColorsCSV, expand the ColorData#csv table, and then select ColorName. The RadioButtonList is now bound to the data source.
In Solution Explorer, choose Local (local.testsettings), open the context menu, and then choose Open.
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 cursor moves to the next row in the database.
Note
All the results are stored in memory. Therefore, using the One run per data source row option will not scale well to large data sets. To run through all rows in a large dataset, the recommended approach is to run the Web performance test in a single user load test. To run through each row one time, select the data table in the Web performance test and set Access Method to unique. The load test will not have the same memory constraints as the Web performance test.
Choose Close.
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
In the Web Performance Test Editor, choose Run Test to start your Web performance test and display the Web Performance Test Results Viewer.
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.
Choose the Context tab and observe how different values are bound into the context on the two runs. Each bound column is set to a context parameter of the form "DataSource1.Table1.ColumnA".
Next Steps
In this walkthrough you added data binding to a Web performance test, using a CSV file. To learn about binding to other data sources, see the following:
How to: Add Data Binding to a Web Request
Walkthrough: Adding Data Binding to a Web Performance Test (XML File)
Walkthrough: Adding Data Binding to a Web Performance Test