Load Testing ASP.NET Applications with Visual Studio 2010

By Peter Bromberg

Quick introduction to the Web Load Test features of Visual Studio 2010

Many developers are not even aware that you can set up and run some very sophisticated web load tests for an ASP.NET Application right from within Visual Studio -- the Ultimate Edition. I don't know if this is because they don't think testing is important, or just because of lack of knowledge.

I think testing is very important, and I've been doing it with .NET since 2001, when I was a lead on a Microsoft - sponsored project to develop banking middleware in what was then a very new .NET Platform. I spent the better part of three weeks at the Microsoft facililty in Charlotte learning all the tricks of the trade from some very smart 'softies. The lessons I learned there have stayed with me ever since. And those lessons are: Test, Test, and Test! Not just unit tests, but load and performance tests as well. Test all your "stuff" thoroughly BEFORE you put it into production!

Testing helps remove that sinking feeling in the stomach when software you've put into production does bad things! Web Load Testing is also useful in production scenarios - for example, say you've decided to switch ASP.NET to WebGarden mode. How do you find the optimal number of processes? You can write a web load test for that and get realtime performance metrics that will enable you to know for sure. Web Load Testing can also be used to measure performance and bottlenecks in WCF RIA Services. You can enlist multiple machines as controllers and multiple machines as agents.

In my book, developers who do not test their software are simply -- not developers.

Let's do a quickie intro into how to set up a web load test project in Visual Studio, Ultimate Edition. I guarantee that this quickie will get you to first base faster than anything else you may have seen. But after that, it's up to you to study some more. All I want to do here is get you to "first base" with the Test platform.

First, we need to set up a load test repository in SQL Server or SQL Express. If you do not have a database named "LoadTest2010", then open up SQL Server Management Studio (SSMS) and use the File/Open/File dialog from the top left of the menu to load the loadtestresultsrepository.sql script from "C:\Program Files (x86)\Microsoft Visual Studio 10\Common7\IDE" (Remove the "(x86)" from the path if you have a 32-bit OS). Execute the script and you are done.

Now in Visual Studio, from the top TEST menu, choose "Manage Test Controllers" and configure your Load Test Results Store to your new database, LoadTest2010.

You are now ready to set up a test.

1) In the same solution as your ASP.NET project, add a new Test project.
2. Right click the TestProject1 node in Solution Explorer, and you will see you have a number of options. Choose "Add", and you'll see you have the choice of a number of different kinds of tests. Choose a "Web Performance Test". You'll notice that Internet Explorer comes up; this is the Web Test Recorder. You can enter the url of the initial page you want to test here. The test recorder will record everything you do: logging in, navigating to other pages, and so on. When you are done, click the "Stop Recording" link. You've now configured a web test. Note that if your project is configured to use the Web Development Server and not IIS, the WebDev server must be running!




3) Now lets add a load Test. Again from the project context menu, choose Add, and this time choose the "Load Test" option. You'll see the following wizard come up:



The wizard has many options that you will probably want to explore and study, but for now, let's just "get to First Base" by clicking through. When you get to the "Test Mix" Wizard page, of course you must add your WebTest1 that you added in step 2. When you've completed the Wizard, you'll now have a complete load test, ready to run!

4) To run your load test, just right- click on it and choose "Run Test". You'll get to see some nice performance graphs in real time, and your ASP.NET Load testing career is now in full swing! Obviously, there is a lot more to study. To find more information, visit the MSDN Forum here. Another great resource is the Performance Testing Quick Reference Guide on codeplex.com.

Popularity  (10536 Views)
Picture
Biography - Peter Bromberg
Peter Bromberg is a C# MVP, MCP, and .NET expert who has worked in banking, financial and telephony for over 20 years. Pete focuses exclusively on the .NET Platform, and currently develops SOA and other .NET applications for a Fortune 500 clientele. Peter enjoys producing digital photo collage with Maya,playing jazz flute, the beach, and fine wines. You can view Peter's UnBlog and IttyUrl sites. Follow Microsoft MVP
Create New Account
Article Discussion: Load Testing ASP.NET Applications with Visual Studio 2010
Peter Bromberg posted at Sunday, June 06, 2010 12:13 PM
reply
Anthony replied to Peter Bromberg at Monday, July 05, 2010 10:32 AM
"I don't know if this is because they don't think testing is important, or just because of lack of knowledge"

Testing is important to us, in-fact I think its a shame these features aren't available in Professional edition.
VS is fantastic, but the price leap from pro to ultimate is too much.

I think there should be a more granular pricing where we "professionals" could add features like load testing support for a smaller fee, rather than getting the next version up with loads of features we will never use
reply
Peter Bromberg replied to Anthony at Monday, July 05, 2010 10:32 AM
I agree, but there are other options. For example Web Stress Tool (formerly known as "Homer") is still free and works great. You just have to hunt it down, since Microsoft no longer makes the installer available.
reply