Export (0) Print
Expand All

Walkthrough: Adding a Loop to a Web Performance Test

In this walkthrough, you will add a simple counting loop to a Web performance test that will cause a Web request in a Web performance test to run through several iterations.

You can add loop logic to Web performance tests that are configured with specific conditional rules and properties. This provides a simple way to have requests within a Web performance test run multiple times. For more information, see Adding Loop and Branch Logic to Web Requests in Web Performance Tests.

In this walkthrough, you will perform the following tasks:

  • Add a counting loop to a Web performance test

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

To complete this walkthrough, you need the following:

Unknown List Class

Consider the following potential issues when using loops in a Web performance test or a load tests using the Web performance test:

  • When you run the Web performance test on its own, that is, not in a load test, the entire Web test result is kept in memory. Therefore, a Web performance test that contains a loop with a lot of iterations can consume a lot of memory.

  • When you run this Web performance test in a load test, if the test takes a long time to run it will have an impact on the test mix in the load test. The load test engine will treat running the Web performance test as a single iteration. If, in fact, the Web performance test is running many iterations, you will not get the desired mix.

In general, an iteration through the Web performance test should be a model of what a single user will do on the site. It’s possible that some users might add several items to a shopping cart in a single session but that does not skew the model. However, looping should not be used to have a single user looping hundreds of times. Instead, let the load engine schedule that particular user hundreds of times. When possible, use less than 10 iterations in your loops.

For this walkthrough, you will have to revert the changes that you made to the Local (local.testsettings) test settings that were made in the walkthrough Walkthrough: Adding Data Binding to a Web Performance Test (CSV File).

To Revert the Test Settings Changes

  1. On the Test menu point to Edit TestSettings, and then click Local (local.testsettings).

  2. In the Configure Test Settings dialog box, select Web Test in the left pane, and then select the Fixed run count option in the right-side pane. Make sure that its value is set to 1.

  3. Click Close.

  4. Click Yes when you are prompted to save changes.

Add the Counting Loop

  1. In the Web Performance Test Editor, find the request that you changed in Walkthrough: Adding Data Binding to a Web Performance Test (CSV File) to bind to ColorsCSV. This should be the second node in the request list.

    Important noteImportant

    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={{ColorsCSV.ColorsCSV#csv.ColorName}}.

  2. In the Web Performance Test Editor, right-click the identified node and then click Insert Loop.

    The Add Conditional Rule and Items to Loop dialog box appears.

  3. On the left side of the dialog box, in the Select a rule list, click Counting Loop.

  4. On the right side of the dialog box, under Properties for selected rule, under the Options header change the value for Max Number of Iterations to 8.

  5. Under the Properties header, for the Context Parameter Name property type Loop Counter.

  6. Change the value for Number of Iterations to 8.

  7. Click OK.

  8. In the Web Performance Test Editor, expand the Data Sources node, expand the ColorsCSV node, expand the Tables node and then select the ColorsCSV#csv node.

  9. In the Properties window, change the value for the Access Method to Random.

To Verify the Counting Loop

  1. In the Web Performance Test Editor, click Run Test to start your Web performance test and display the Web Performance Test Results Viewer.

  2. In the Web Performance Test Results Viewer there will be eight loop iterations of the Web request that you added the counting loop to. These iterations randomly select either the red or the blue ASP pages.

    NoteNote

    You might have to scroll up in the Web Performance Test Results Viewer to see all the loop iterations.

    NoteNote

    The errors in the test are caused by the response URL validation rule because the URL does not match the URL 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.

Community Additions

ADD
Show:
© 2015 Microsoft