Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
In Visual Studio 2010 Essential Training, author Walt Ritscher demonstrates how to use Visual Studio 2010 Professional to develop full-featured applications targeting a variety of platforms. Starting with an overview of the integrated developer environment, the course covers working with code editors, navigating and formatting code, and deploying applications. Also included are tutorials on running performance and load tests, and debugging code. Exercise files accompany the course.
I've found that many developers are not aware that you can set up and run complex web load tests for an ASP.NET Application. You can do this right from within Visual Studio, as long as you have the Ultimate edition. If you don't have the Ultimate version, you won't be able to follow along with this demonstration. I'm going to create two types of tests: a performance test which is intended to determine how fast some aspect of a system performs under workload, then I'll create a load test which is a simulated real-world test that exercises the web site by running the designated performance tests.
I'm going to use his project called WebsiteToLoadTest to write my tests against. This is just a simple ASP.NET site. Now before you run the test, make sure you are running Visual Studio as an administrator; otherwise you will not be able to perform the load tests. Next, I'm going to run my application. Since I'm running on a development server, I need the copy the port number from my local host before I create my web tests. So I'll copy this, and then I'll close that browser window.
Then I'm going to go to my Test menu and create a brand-new test. I'm starting by creating a web performance test. I'm going to call this one GoToAsp. I'll pick a language, C#--although it doesn't matter for this example--and then I'll click OK. Visual Studio realizes I haven't created a test project yet. I'll call this one BasicLoadTests and then click Create and then OK to this dialog. A number of things has happened.
If you look in the Solution Explorer, you'll see there is a Solution folder has been created, also a new GoToAsp.webtest file has been created, and then Visual Studio has launched this version of Internet Explorer with this special plug-in running called the Web Test Recorder. What I'm going to do is I'm going to paste that URL in that I copied a few seconds ago. And now I'm going to go back and restart my web server because it's not running. So we will go back over here and choose Debug > Start Debugging. That looks better.
So now what I'll do is I step through the test steps. The user is going to click on this link, which takes him to another site, and they're going to click on the Back button. Now, I'm done recording the test, so I'll click Stop. At this point, you'll see a dialog. You might have to wait a few seconds for this dialog to disappear. Next, I'm going to create a second web test by going to Test > New Test > Web Performance Tests. I'm going to call these one FailedLogin, place it in the same test project, verify that my browser is still running. It's not, so I'm going to have start my browser. And what the user is going to do this time is they are going to click on this Log In button.
I'll type in their name and a bad password, and click Log In. It fails and then the user goes back to the homepage. That's my next test. I'll choose Stop, and save. Now I've got my two performance tests. I'm going to create a load test. Remember that a load test simulates workload on the site. Now I'm going to go up to Test > New Test > Load Test. I will go ahead and leave it as the default name, and then click on OK. Since I'm simulating users coming to this site, I am going to go through the Scenario system here.
First, it's going to ask me to give the name for this scenario. I'm going to pick the defaults. I'm going to suggest that we have 25 users exercising the site. This is changeable, naturally. I'm going to skip over this one, and then I'm going to come in here and add those two tests I just created. I'm going to add the FailedLogin and then GoToASP, and then I'll click on OK, and then I click on Next. Here I can choose how to simulate what type of network connections our users are connecting with.
So I can come here and choose Add, and say that some of our users are coming in on a 56K modem--about 10% are using that--and then I'll click on Add and have other network settings here. Now I don't want a actually keep these items in here, because if I do, it's going to install some extra network emulators which I don't want to wait for that process to happen. So I'm going to choose Remove, and Remove, and then click on Next. Here, I can pick the browser mix. Again, I go to the Add button, and say that we've got some people coming to you with Firefox 3.
20% of our users are using Firefox 3, and 5% of our users are using Chrome too, and so on. So I pick these mixes, and I'm going to remove these for testing purposes today, and then I click on Next. This one allows me to add other computers to run against the server. I'm just going to use my single computer today, And then here, I'm going to pick the test duration time. I don't want this to be too long, so I am just going to type in 30 seconds for the test duration. I will click on Finish, and now I'm ready to run my test.
I think before that, I should build my application. I will choose Build > Build Solution, and then I'll go to my Test > Window and choose Test List Editor. And notice I have three tests. I am only going to run the LoadTest1. I don't need to run these two individual ones because they are going to be the part of the LoadTest. I also need to verify that my web site is running. I will switch over here, go to my Test editor and run the test. After waiting 30 seconds, the test completes. I can then click on this hyperlink here to see my test results.
I see that my test passed. I can also right-click here and choose View Test Results Details and see a more detailed result screen. Here, I can see a summary, when the test was run, how long it took, what were my slowest pages, and then I can look at a set of graphs, a set of detailed table information. I see that I had 13 total test run on FailedLogIn and 28 tests were run on GoToASP and how long each one of those test took. Quite a bit of details here about what's happening on your web site.
There is more to learn about performance and load testing. For example, you should never run the load test from your developer computer. Instead, you should set up a testing ring and have it test the site. This enables you to scale your test to simulate a realistic runtime load. You can also create simulated users, or use data-driven tests to simulate users' search strings and other complex test scenarios.
Find answers to the most frequently asked questions about Visual Studio 2010 Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.