Walkthrough: Creating a Web Performance Test that Requires a Login and Logout
In this walkthrough you create a simple Web application that contains a login step and a logout step. The application simulates a shopping application, but does not contain functional code. Finally, you create a Web performance test to test the application.
In this walkthrough, you will perform the following tasks:
Create a simple Web application.
Create a Web performance test.
Extract new Web performance tests from an existing Web performance test.
Compose a new Web performance test from existing Web performance tests.
Prerequisites
For this walkthrough you will need:
- Visual Studio 2010 Ultimate
Creating the Web Application
To create the Web application
In Visual Studio 2010 Ultimate, on the File menu, click File and then click Project.
The New Project dialog box appears.
Under Installed templates, expand the programming language you prefer and then click Web.
In the list of Web project types, select Empty ASP.NET Application.
Note
You will write minimal code in this walkthrough.
In the Name box, type ShoppingWebApp.
In the Location box, specify the folder where you want to create your Web application.
Select Create directory for solution.
Click OK.
On the Project menu, choose Add New Item.
The Add New Item dialog box appears.
In the list of items, choose Web Form.
In the Name text box, type Default.aspx and then click Add.
To create the home page for the Web application
In Solution Explorer, right-click Default.aspx and click View Designer.
A blank page is displayed.
If the toolbox is not visible, click View and then click Toolbox.
From the Standard group, drag five buttons onto the page. Use the following table to complete this step.
Note
Double-click each button to open the button click event and add the code.
Control
Text Property
Button Click Code
Button1
Go to Log In
Response.Redirect("Login.aspx");
Button2
Product 1
Response.Redirect("Product1.aspx");
Button3
Product 2
Response.Redirect("Product2.aspx");
Button4
Shopping Cart
Response.Redirect("Cart.aspx");
Button5
Go to Log Out
Response.Redirect("Logout.aspx");
On the File menu, click Save All.
To add pages to the Web application
On the Website menu, click Add New Item.
In the Add New Item dialog box, click the Web Form template, name it Login.aspx, and then click Add.
At the bottom of the document window, click the Design tab to switch to design view.
Drag a button onto the page.
Drag a text box onto the page.
Repeat steps 1 through 4 four more times. Use the following table to complete this step:
Web Page
Control
Text Property
Button Click Code
Login.aspx
TextBox1
-
-
Login.aspx
Button1
Log In
Response.Redirect("Default.aspx");
Product1.aspx
Button1
Add to Cart
Response.Redirect("Default.aspx");
Product2.aspx
Button1
Add to Cart
Response.Redirect("Default.aspx");
Cart.aspx
Button1
Buy
Response.Redirect("Default.aspx");
Logout.aspx
Button1
Log Out
Response.Redirect("Default.aspx");
Note
There is no real functionality in this Web application. Submitting each page returns the user to the home page. This functionality is sufficient for the purposes of this walkthrough.
On the File menu, click Save All.
To test the Web application manually
In Solution Explorer, right-click Default.aspx and then click Set As Start Page.
Press CTRL+F5 to run the Web application in the browser. You will see the home page, Default.aspx.
Note
This starts the ASP.NET Development Server that runs the Web application that your Web performance test will test. You will see the ASP.NET Development Server icon in the notification area, at the far right of the taskbar.
Copy the address of the Web application to the clipboard or a notepad file. You will need the address for a later step in the walkthrough. For example, the address might resemble this: https://localhost:<PortNumber>/ShoppingWebApp/Default.aspx
Click Go to Log In. The page Login.aspx opens.
Type your name in the text box and then click Log In. The home page opens.
Click Product 1. The page Product1.aspx opens.
Click Add to Cart. The home page opens.
Click Product 2. The page Product2.aspx opens.
Click Add to Cart. The home page opens.
Click Shopping Cart. The page Cart.aspx opens.
Click Buy. The home page opens.
Click Go to Log Out. The page Logout.aspx opens.
Click Log Out. The home page opens.
Close the Web browser.
Creating the Web Performance Test
Now you are ready to create a Web performance test that lets you to test this application.
To create the Web performance test application
In a new instance of Visual Studio 2010 Ultimate, on the File menu, point to New and then click Project.
The New Project dialog box appears.
Under Installed Templates, expand Visual Basic or Visual C# according to your preference, and select the Test node.
Under the list of templates, click Test Project.
In the Name box, type ShoppingWebAppTest.
In the Location box, type the name of the folder where you saved the Web application. For example, type the folder name C:\WebSites\ShoppingWebApp.
Click OK.
The test project is created.
Note
By default, Visual Studio will add a unit test file and a text file that has information about authoring tests. You do not need these files for this walkthrough. Therefore, you can delete them. If you do not delete the files, they will not affect the walkthrough.
On the Test menu, click New Test.
The Add New Test dialog box appears.
In the Add New Test dialog box, select Web Performance Test, name the test WebTest1.webtest, and click OK.
A new Web performance test file that is named WebTest1.webtest is added to your project, and the Web Performance Test Recorder opens inside a new instance of Internet Explorer.
In the browser's address bar, type the address of the Web application that you copied in a previous step, and press enter.
Note
Visual Studio starts to display the Web performance test URLs in the Web Performance Test Recorder as it is recording.
Click Go to Log In. The page Login.aspx opens.
Type your name in the text box and then click Log In. The home page opens.
Click Product 1. The page Product1.aspx opens.
Click Add to Cart. The home page opens.
Click Product 2. The page Product2.aspx opens.
Click Add to Cart. The home page opens.
Click Shopping Cart. The page Cart.aspx opens.
Click Buy. The home page opens.
Click Go to Log Out. The page Logout.aspx opens.
Click Log Out. The home page opens.
Click Stop on the Web Performance Test Recorder to stop recording.
Internet Explorer will close and you will see the Web performance test in the Web Performance Test Editor as a list of URLs. After you stop recording, you can modify the test.
On the File menu, click Save All.
To run the Web performance test application
In the Web Performance Test Editor, click Run Test on the toolbar.
The test starts to run, and a Web Performance Test Results Viewer displays each request in the test. A Test Results window displays the result for the entire test.
In the Test Results window verify that the test passed.
In the Web Performance Test Results Viewer select some of the requests in the list and then examine the results that are shown in the Web browser in the lower pane. Verify that the test is running correctly.
Extracting New Web Performance Tests
You can create new Web performance tests by extracting individual requests from an existing Web performance test. For more information, see How to: Extract Requests in a Web Performance Test to Create a New Web Performance Test.
To extract new Web performance tests from an existing Web performance test
Open WebTest1 in the Web Performance Test Editor.
In the request tree, right-click WebTest1 and then click Extract Web Test.
The Extract Web Test dialog box appears.
In Web test name type Login.
In the Choose first item for the Web test drop-down select the first request. The request should resemble the following:
https://localhost:<PortNumber>/ShoppingWebApp/Default.aspx
In the Choose last item for the Web test drop-down list select the third request. The request should resemble the following:
https://localhost:<PortNumber>/ShoppingWebApp/Login.aspx
Click OK.
A new Web performance test named Login is created. In the Web Performance Test Editor, Login is added to the request tree in place of the individual requests that you extracted. In Solution Explorer, Login.webtest is added to the project list.
In the request tree, right-click WebTest1 and then click Extract Web Test.
The Extract Web Test dialog box appears.
In Web test name type BrowseAndBuy.
In the Choose first item for the Web test drop-down select the first request after Login. The request should resemble the following:
https://localhost:<PortNumber>/ShoppingWebApp/Default.aspx
In the Choose last item for the Web test list select the sixth request. The request should resemble the following:
https://localhost:<PortNumber>/ShoppingWebApp/Cart.aspx
Click OK.
A new Web performance test named BrowseAndBuy is created. In the Web Performance Test Editor BrowseAndBuy is added to the request tree in place of the individual requests that you extracted. In Solution Explorer, BrowseAndBuy.webtest is added to the project list.
In the request tree, right-click WebTest1 and then click Extract Web Test.
The Extract Web Test dialog box appears.
In Web test name type Logout.
In the Choose first item for the Web test list select the first request after BrowseAndBuy. The request should resemble the following:
https://localhost:<PortNumber>/ShoppingWebApp/Default.aspx
In the Choose last item for the Web test list select the last request. The request should resemble the following:
https://localhost:<PortNumber>/ShoppingWebApp/Logout.aspx
Click OK.
A new Web performance test named Logout is created. In the Web Performance Test Editor Logout is added to the request tree in place of the individual requests that you extracted. In Solution Explorer, Logout.webtest is added to the project list.
Confirm that there are no individual requests remaining in the Web performance test request tree. That is, WebTest1 now consists completely of calls to other Web performance tests.
On the File menu, click Save All.
To run the Web performance test application
In the Web Performance Test Editor, click Run Test on the toolbar.
The test starts to run, and a Web Performance Test Results Viewer displays each request in the test. A Test Results window displays the result for the entire test.
In the Test Results window verify that the test passed.
In the Web Performance Test Results Viewer select some of the requests in the list and then examine the results that are shown in the Web browser in the lower pane. Verify that the test is running correctly.
Note
In Web Performance Test Results Viewer there are now collapsible nodes named WebTest1.Login, WebTest1.BrowseAndBuy, and WebTest1.Logout in the tree. This helps you review the parts of your test more easily.
Composing New Web Performance Tests
You can create a new Web performance test by composing existing Web performance tests. For more information, see How to: Insert a Call in a Web Performance Test to Another Web Performance Test.
To compose a new Web performance test from existing Web performance tests
On the Test menu, click New Test.
The Add New Test dialog box appears.
In the Add New Test dialog box, select Web Performance Test, name the test AllTest.webtest, and click OK.
A new Web performance test file that is named AllTest.webtest is added to your project, and the Web Performance Test Recorder opens inside a new instance of Internet Explorer.
Click Stop on the Web Performance Test Recorder to stop recording without browsing.
Internet Explorer will close and you will see the Web performance test in the Web Performance Test Editor. The test is empty because you did not browse.
In the request tree, right-click AllTest and then click Add Call to Web Test.
The Choose Test dialog box appears.
Click Login and then click OK. The Login Web performance test is added to the request tree.
In the request tree, right-click AllTest and then click Add Call to Web Test.
The Choose Test dialog box appears.
Click BrowseAndBuy and then click OK. The BrowseAndBuy Web performance test is added to the request tree.
In the request tree, right-click AllTest and then click Add Call to Web Test.
The Choose Test dialog box appears.
Click Logout and then click OK. The Logout Web performance test is added to the request tree.
On the File menu, click Save All.
To run the Web performance test application
In the Web Performance Test Editor, click Run Test on the toolbar.
The test starts to run, and a Web Performance Test Results Viewer displays each request in the test. A Test Results window displays the result for the entire test.
In the Test Results window verify that the test passed.
In the Web Performance Test Results Viewer select some of the requests in the list and then examine the results that are shown in the Web browser in the lower pane. Verify that the test is running correctly.
Next Steps
Now that you have a Web performance test, you can add it to a load test. You can create a load test that performs the Login and Logout steps only one time per virtual user, and tests the BrowseAndBuy step multiple times per virtual user.
See Also
Tasks
How to: Create a New Web Performance Test Using the Web Performance Test Recorder
How to: Edit an Existing Web Performance Test Using the Web Performance Test Editor