Walkthrough: Create and run a load test that contains unit tests

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

In this walkthrough you create a load test that contains unit tests.

Note

Web performance and load test functionality is deprecated. Visual Studio 2019 is the last version where web performance and load testing will be fully available. For more information, see the Cloud-based load testing service end of life blog post. To reduce the impact on users some minimum support is still available in Visual Studio 2022 Preview 3 or later. Users should also note web performance and load test functionality only supports Internet Explorer which is not available on Windows 11 and some versions of Windows 10. Read more on Internet Explorer Lifecycle policy.

This walkthrough steps you through creating and then running a load test using Visual Studio Enterprise. A load test is a container of web performance tests and unit tests. You create load tests with the New Load Test Wizard.

A load test also exposes many run-time properties that can be modified to generate the desired load simulation. In this walkthrough, you use the New Load Test Wizard to add unit tests to a load test.

In this walkthrough, you will complete the following tasks:

Create a load test containing unit tests using the New Load Test Wizard

To start the New Load Test Wizard

  1. Make sure you have installed the Web performance and load testing tools component described in Create a load test project.

  2. Open the Bank solution that you created in Walkthrough: Creating and running unit tests for managed code.

  3. In Solution Explorer, open the shortcut menu for the Bank solution node, choose Add, and then choose New Project.

    The Add New Project dialog box displays.

  4. In the Add New Project dialog box, expand Visual C# and choose Test. From the list of templates, choose Web Performance and Load Test Project and in the Name field, type BankLoadTest. Choose OK.

    The BankLoadTest web performance and load test project is added to the solution.

  5. Open the shortcut menu for the new BankLoadTest web performance and load test project, choose Add, and then choose Load Test.

  6. The New Load Test Wizard starts.

  7. The Welcome page of the New Load Test Wizard is the first page.

  8. Choose Next.

To edit settings for load test scenario

  1. In the Enter a name for the load test scenario text box, type ScenarioSample.

    A scenario is a grouping mechanism. It consists of a set of tests and the properties for running those tests under load.

  2. Set the Time Profile Think to Use normal distribution centered on recorded think times. Think times represent the time that a user would ponder a web page before going on to the next page.

  3. Choose Next when you are finished.

To edit load pattern setting for test scenario

  1. Choose Step load.

    Note

    You can choose from two types of load patterns: constant and step. Each type has its function in load testing, but for the purposes of this walkthrough choose Step load.

  2. Set Start user count to 10 users.

  3. Set Step duration to 10 seconds.

  4. Set Step user count to 10 users/step.

  5. Set Maximum user count to 100 users.

  6. Choose Next.

To select test mix model for the scenario

  1. Under How should the test mix be modeled, select Based on the total number of test.

  2. Choose Next.

To add unit tests to the scenario

  1. The next step is to Add tests to a load test scenario and edit test mix.

  2. Choose Add to select tests.

  3. Choose the CreditTest unit tests listed in the Available Tests pane, which lists all the web performance tests and unit tests in the web performance and load test project.

  4. Choose the arrow to add the CreditTest unit test to the Selected Tests pane.

  5. Repeat steps 3 and 4 for the DebitTest and FreezeAccountTest unit tests.

  6. When you have finished adding the three unit tests, choose OK.

    You are presented with the test mix.

  7. Move the slider under Distribution for the CreditTest slightly to the right to adjust the test distribution. Notice that the other sliders move to the left automatically so that the distribution remains at 100%.

  8. Choose Next.

To select network mix for test scenario

  1. Select the LAN connection type to add to the network bandwidth mix.

    You can add more network types. Use the sliders to adjust the test distribution and weighting.

  2. Choose Next.

To specify computers to monitor with counter sets during load test run

  1. Choose Next.

    For more information about the counter sets, see Specify the counter sets and threshold rules for computers in a load test.

To edit run setting for load test

  1. Select Load test duration and then set Run Duration to 2 minutes in order to smoke test your load test.

    When you build your load tests, it is a good practice to validate that everything is configured correctly and running as expected by running a short, light load test. This process is known as smoke testing.

  2. Choose Finish. Your Load test is opened in the Load Test Editor.

Run the load test

After you have created the Load test, run it to view how your bank application responds to the load simulation. While a load test is running, you see the Load Test Analyzer window.

To run the load test

  1. With a Load test open in the Load Test Editor, choose the green Run Test button in the toolbar. Your load test starts to run.

  2. If your test simulation exceeds any thresholds, icons appear in the tree control nodes to indicate a threshold violation. Errors have a red circle overlay, warnings have a yellow triangle overlay. You can find a counter that exceeded the threshold and graph it by dragging the icon onto the graph. You can do this while the test is running.

See also