Walkthrough: Creating and Running a Load Test Containing Unit Tests
In this walkthrough you create a load test that contains unit tests.
This walkthrough steps you through creating and then running a load test using Visual Studio 2010 Ultimate. A load test is a container of Web performance tests and unit tests. You create load tests with the New Load Test Wizard. For more information about load tests, see Creating and Editing Load Tests.
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. For more information about Web performance tests, see Creating and Editing Web Performance Tests.
In this walkthrough, you will complete the following tasks:
Create a load test that uses unit tests.
Change some of the load test settings.
Run a load test.
Microsoft Visual Studio 2010 Ultimate
Perform the steps in Walkthrough: Creating and Running Unit Tests to create a simple C# class library that contains a test project with some unit tests in it.
To start the New Load Test Wizard
Open the Bank solution that you created in Walkthrough: Creating and Running Unit Tests.
In Solution Explorer, right-click the TestProject1 node. Click Add, and then click Load Test.
The New Load Test Wizard starts.
The Welcome page of the New Load Test Wizard is the first page.
To edit settings for load test scenario
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.
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. For more information, see How to: Set Think Times to Simulate Human Pausing in a Web Performance Test.
Click Next when you are finished.
To edit load pattern setting for test scenario
Click Step load.
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.
Set Start user count to 10 users.
Set Step duration to 10 seconds.
Set Step user count to 10 users/step.
Set Maximum user count to 100 users.
To select test mix model for the scenario
Under How should the test mix be modeled, select Based on the total number of test.
To add unit tests to the scenario
The next step is to Add tests to a load test scenario and edit test mix.
Click Add to select tests.
Click the CreditTest unit tests listed in the Available Tests pane, which lists all the Web performance tests and unit tests in the test project.
Click the arrow to add the CreditTest unit test to the Selected Tests pane.
Repeat steps 3 and 4 for the DebitTest and FreezeAccountTest unit tests.
When you have finished adding the three unit tests, click OK.
You are presented with the test mix.
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%.
To select network mix for test scenario
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.
To specify computers to monitor with counter sets during load test run
For more information about the counter sets, see Specifying the Counter Sets for Computers in a Load Test and Walkthrough: Creating and Running a Load Test Containing Web Performance Tests.
To edit run setting for load test
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.
Click Finish. Your Load test is opened in the Load Test Editor.
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
With a Load test open in the Load Test Editor, click the green Run Test button in the toolbar. Your load test starts to run.
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.