Tuesday, 14 September 2010

Web Performance Testing with Visual Studio 2010

Performance testing and debugging is a major focus of Visual Studio 2010 Ultimate. Web testing and load testing have been supported in Visual Studio Team System since the 2005 release, but Visual Studio 2010 offers major improvements.

In the Web performance tests, the addition of Loops and Conditions enables developers to write more complex and intelligent tests against their applications. For load tests, the addition of 64-bit agents and controllers allows you to more effectively use the available hardware resources to generate load. Additionally, changes to the licensing of the load test agents and controllers gives you greater flexibility, making it easier -- and potentially cheaper -- to configure your load test rigs.

Web tests allow you to simulate a user performing a set of operations – typically a defined use case – on your ASP.NET Web application, and validate the responses to see if the application is working as expected. Once you have your Web tests defined, you can knit them together to create a load test to see how well your application performs under stress.

Create Some Web Tests:
Web tests are typically created using the Internet Explorer Web Testing toolbar, which records a human user clicking through a Web application. In the sample code for this article, our Visual Studio Test Project is called Com.Benday.WebTesting.WebTests. You can create a new Web test by right-clicking the project and choosing new Web Test (in Visual Studio 2010, Web Performance Test) from the Add menu. See the below picture.


When you add a new Web Test to your project, Visual Studio will open up Internet Explorer and you should see the Web Test Recorder panel in the browser. You can now go to a Web site and start using it just like you normally would and, as you go, you'll see your actions being recorded by the Web Test Recorder.



















Figure 1. The Web Test Recorder toolbar in Internet Explorer


When you've finished performing the actions that you wanted to record, click the Stop on the Web Test Recorder toolbar and you'll be taken back to Visual Studio and you'll see your actions in a *.webtest file (Figure 2).










Figure 2. A new Web Test in Visual Studio

Layered framework for Visual studio 2010 Automation testing

Base your layered architecture on three layers: script layer, business layer, and framework layer. This pattern presents an overview of the responsibilities of each layer and the components that compose each layer.








The above framework has 3 layers:
  • Framework Layer
  • Business Layer
  • Scripting Layer
Framework Layer:  This layer is generic and common across all the projects. It consist of generic components which are useful with in the organization across all the projects. It would be good declare all the possible components as interfaces with in this layer. Below are the compoenets that goes into this layer.
  1. Utilities
  2. Data management
  3. Configuration management
  4. Logging 
  5. Reporting
  6. Logging
  7. Reporting
  8. Exception handling 
  9. Recovery scenarios
  10. Screen recording
  11.  Data access layer
  12.  Object wrapper functions
  13. Data driven driver classes
Business Layer: This layer is specific to project, where the re usable libraries are developed. Each screen will have one class for handling the testing. Common functions will go into separate library. Every project will have their own implementation of the interface that are created in the Framework layer.


Scripting Layer: This layer is responsible for the scripting, each script is responsible for one screen in the application. Scripts will call the business layer components to pass the test data.