Look at Web Performance Test in Visual Studio 2012

In this article, we will look into Web Performance testing, its purpose and how to use it. In Visual Studio 2012, we can use a Web Performance project to perform load testing. A load test models the expected usage of your website by simulating multiple virtual users who access it at the same time. In a web performance test, multiple users will be simulated to open simultaneous connections to a server and making multiple HTTP requests to the website. This will help us to understand:

  1. How our website performs under light loads for short durations (Smoke testing).
  2. To determine responsiveness of the website (Performance testing).
  3. To check whether the website sustains heavy load for specific time or not (Stress testing).
  4. To understand the behavior of the website in terms of CPU, memory and, response time at various capacities.

We can record the test using a recorder installed along with Visual Studio 2012 Ultimate, integrated with Internet Explorer.
Let's create a sample Web Performance and Load Test Project to understand it further:

Web-Performance-and-Load-Test Project

Click on "Add recording", this will open IE along with a recorder.

Open your website URL and record all actions and click on "Stop Recording" after completion as shown below:


This will generate the code needed to run the web tests as shown below:


We can add\edit form values, query strings and headers to a request as shown below:


Few requests may contain dynamic parameters like session ID, query string and so on. We can detect whether our web test has any dynamic parameters or not, if so then it will show a dialog for promoting it to Web Test parameters.

We can even set conditions on response time, HTTP response code and so on based on which a Web Test is considered as passed as shown below:


Let's run our tests by clicking on the "Run Test" icon as shown below:


We can explore each request's response, web browser output and reason for a web test's failure. This way, we can record our web tests and run it multiple times. This is useful in regression testing.

We can add our Web test to a Load Test for doing stress\performance tests with a specific number of virtual users.