Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

Here’s what you’ll need:

  • Visual Studio Ultimate

To create the Web application

  1. In Visual Studio Ultimate, on the FILE menu, choose New and then choose Project.

    The New Project dialog box appears.

  2. Under Installed templates, expand the programming language you prefer and then choose Web.

  3. In the list of Web project types, select ASP.NET Empty Application.

    Note Note

    You will write minimal code in this walkthrough.

  4. In the Name box, type ShoppingWebApp.

  5. In the Location box, specify the folder where you want to create your Web application.

  6. Select Create directory for solution.

  7. Choose OK.

  8. On the Project menu, choose Add New Item.

    The Add New Item dialog box appears.

  9. In the list of items, choose Web Form.

  10. In the Name text box, type Default.aspx and then choose Add.

To create the home page for the Web application

  1. In Solution Explorer, right-click Default.aspx and choose View Designer.

    A blank page is displayed.

  2. If the toolbox is not visible, choose View and then choose Toolbox.

  3. From the Standard group, drag five buttons onto the page. Use the following table to complete this step.

    Note Note

    Double-click each button to open the button choose event and add the code.

    Control

    Text Property

    Button Choose 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");
    
  4. On the FILE menu, choose Save All.

To add pages to the Web application

  1. On the Project menu, choose Add New Item.

  2. In the Add New Item dialog box, choose the Web Form template, name it Login.aspx, and then choose Add.

  3. At the bottom of the document window, choose the Design tab to switch to design view.

  4. Drag a button onto the page.

  5. Drag a text box onto the page.

  6. Repeat steps 1 through 4 four more times. Use the following table to complete this step:

    Web Page

    Control

    Text Property

    Button Choose 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 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.

  7. On the FILE menu, choose Save All.

To test the Web application manually

  1. In Solution Explorer, right-click Default.aspx and then choose Set As Start Page.

  2. Press CTRL+F5 to run the Web application in the browser. You will see the home page, Default.aspx.

    Note 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.

  3. 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: http://localhost:<PortNumber>/ShoppingWebApp/Default.aspx

  4. Choose Go to Log In. The page Login.aspx opens.

  5. Type your name in the text box and then choose Log In. The home page opens.

  6. Choose Product 1. The page Product1.aspx opens.

  7. Choose Add to Cart. The home page opens.

  8. Choose Product 2. The page Product2.aspx opens.

  9. Choose Add to Cart. The home page opens.

  10. Choose Shopping Cart. The page Cart.aspx opens.

  11. Choose Buy. The home page opens.

  12. Choose Go to Log Out. The page Logout.aspx opens.

  13. Choose Log Out. The home page opens.

  14. Close the Web browser.

Now you are ready to create a Web performance test that lets you to test this application.

To create the Web performance test application

  1. In a new instance of Visual Studio Ultimate, on the FILE menu, point to New and then choose Project.

    The New Project dialog box appears.

  2. Under Installed Templates, expand Visual Basic or Visual C# according to your preference, and select the Test node.

  3. Under the list of templates, choose Web performance and load Test Project.

  4. In the Name box, type ShoppingWebAppTest.

  5. 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.

  6. Choose OK.

    The Web performance and load test project is created which includes a web performance test named WebTest1.webtest.

  7. In Solution Explorer, choose WebTest1.webtest, by opening the shortcut menu, and choosing Rename. Rename the test WebTest1.webtest.

  8. In Solution Explorer, choose WebTest1.webtest, open the shortcut menu, and then choose Open.

    The Web Performance Test Editor displays.

  9. In the Web Performance Test Editor, choose Add Recording from the toolbar.

    Your web browser opens with the Web Test Recorder add on displayed.

    Note Note

    If you don’t see the Web Test Recorder, you must configure the add-ons in your web browser to include it.

  10. In the browser's address bar, type the address of the Web application that you copied in a previous step, and press enter.

    Note Note

    Visual Studio starts to display the Web performance test URLs in the Web Performance Test Recorder as it is recording.

  11. Choose Go to Log In. The page Login.aspx opens.

  12. Type your name in the text box and then choose Log In. The home page opens.

  13. Choose Product 1. The page Product1.aspx opens.

  14. Choose Add to Cart. The home page opens.

  15. Choose Product 2. The page Product2.aspx opens.

  16. Choose Add to Cart. The home page opens.

  17. Choose Shopping Cart. The page Cart.aspx opens.

  18. Choose Buy. The home page opens.

  19. Choose Go to Log Out. The page Logout.aspx opens.

  20. Choose Log Out. The home page opens.

  21. Choose 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.

  22. On the FILE menu, choose Save All.

To run the Web performance test application

  1. In the Web Performance Test Editor, choose 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.

  2. In the Test Results window verify that the test passed.

  3. 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.

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 an Existing Web Performance Test to Create a New Web Performance Test.

To extract new Web performance tests from an existing Web performance test

  1. Open WebTest1 in the Web Performance Test Editor.

  2. In the request tree, right-click WebTest1 and then choose Extract Web Test.

    The Extract Web Test dialog box appears.

  3. In Web test name type Login.

  4. In the Choose first item for the Web test drop-down select the first request. The request should resemble the following:

    http://localhost:<PortNumber>/ShoppingWebApp/Default.aspx

  5. In the Choose last item for the Web test drop-down list select the third request. The request should resemble the following:

    http://localhost:<PortNumber>/ShoppingWebApp/Login.aspx

  6. Choose 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.

  7. In the request tree, right-click WebTest1 and then choose Extract Web Test.

    The Extract Web Test dialog box appears.

  8. In Web test name type BrowseAndBuy.

  9. In the Choose first item for the Web test drop-down select the first request after Login. The request should resemble the following:

    http://localhost:<PortNumber>/ShoppingWebApp/Default.aspx

  10. In the Choose last item for the Web test list select the sixth request. The request should resemble the following:

    http://localhost:<PortNumber>/ShoppingWebApp/Cart.aspx

  11. Choose 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.

  12. In the request tree, right-click WebTest1 and then choose Extract Web Test.

    The Extract Web Test dialog box appears.

  13. In Web test name type Logout.

  14. In the Choose first item for the Web test list select the first request after BrowseAndBuy. The request should resemble the following:

    http://localhost:<PortNumber>/ShoppingWebApp/Default.aspx

  15. In the Choose last item for the Web test list select the last request. The request should resemble the following:

    http://localhost:<PortNumber>/ShoppingWebApp/Logout.aspx

  16. Choose 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.

  17. 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.

  18. On the FILE menu, choose Save All.

To run the Web performance test application

  1. In the Web Performance Test Editor, choose 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.

  2. In the Test Results window verify that the test passed.

  3. 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 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.

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

  1. In Solution Explorer, open the shortcut menu on the ShoppingWebAppTest Web performance and load test project and choose Add. Then choose Web Performance Test.

    A new Web performance test file that is named WebTest2.webtest is added to your project, and the Web Performance Test Recorder opens inside a new instance of Internet Explorer.

  2. Choose 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.

  3. In the request tree, right-click WebTest2 and then choose Add Call to Web Test.

    The Choose Test dialog box appears.

  4. Choose Login and then choose OK. The Login Web performance test is added to the request tree.

  5. In the request tree, right-click WebTest2 and then choose Add Call to Web Test.

    The Choose Test dialog box appears.

  6. Choose BrowseAndBuy and then choose OK. The BrowseAndBuy Web performance test is added to the request tree.

  7. In the request tree, right-click WebTest2 and then choose Add Call to Web Test.

    The Choose Test dialog box appears.

  8. Choose Logout and then choose OK. The Logout Web performance test is added to the request tree.

  9. On the FILE menu, choose Save All.

To run the Web performance test application

  1. In the Web Performance Test Editor, choose 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.

  2. In the Test Results window verify that the test passed.

  3. 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.

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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.