Tuesday, July 16, 2013

Recording VSTS webtest of windows application which uses https web services

Whenever we develop a web site or web application, it is mandatory that we should do load testing before production. It will give us an idea about how many users and requests it can handle per second in a given server environment. In theory its easy to say we should do the load testing. But in practice, very less people knows, how it is being worked out and what are the software tools used to do load testing.

One of the load testing tool is Visual Studio itself ! But before going into load testing in Visual studio, let us see what a load testing software in general should provide and how a load testing is carried out.

Features of load testing software

  • Recording
    • Ability to record the different use cases of the application. Mainly uses script for storing purpose.
    • Ability to add parameters / tokens into the recorded use cases / script for handling virtual users and passing other runtime values.
  • Play back
    • Ability to run the recorded use cases / scripts by replacing the tokens with run time values
    • Ability to run simultaneously from multiple machines or agents.
    • Controller agent model to collect data from the nodes which are executing the scripts.
    • Ability to create virtual users in the controller agent environment.

Steps to do load testing

  1. Record the use cases in a format which can be playable
  2. Adding parameters (optional)
    1. Add tokens or place holders to the recorded script so that it can be replaced by actual values at run time
    2. Write the token / parameter replacement logic.
  3. Define web load test cases. eg: 25 virtual users
  4. Setup the agents.
  5. Run the recorded load test cases and collect the results.

Web performance load testing using Visual Studio

This feature is available in high end versions (Ultimate) of Visual Studio. If your Visual Studio supports load testing, you can see the webtest template and load test template. If your application is a web site its very easy to record the scripts. This is because the Visual Studio has an in built mechanism to record the http(s) traffic from internet explorer. If your internet explorer is in record mode, you can easily perform use cases and record the action. But if you are developing a windows application which uses http(s), it is little difficult to record because Visual Studio cannot intercept your windows desktop application to capture the http(s) traffic. So what to do? In fact that is the aim of this post.

Recording visual studio web test in desktop world

There is a really really useful tool called fiddler. It must be familiar to the web developers but not for windows developers. This tool can act as proxy which sits between any application and the network to capture all the http(s) requests and responses. Now a days most of its duties can be done by the F12 browser tools. But in the desktop environment, fiddler still has importance. Below is the sequence to create web test of windows applications using fiddler.
  1. Run Fiddler
    1. Setup support for https if required
  2. Run the application
  3. Execute a use case
  4. Goto fiddler and select File -> Export Sessions -> All Sessions
  5. Select Visual Studio WebTest
  6. Add the exported web test to Visual Studio project.
  7. Add tokens / parameters to the web test.
  8. Clear the fiddler session
  9. Repeat the steps 3-8 for all the use cases in your application which you want to load test.

No comments: