Inside VSTS

VSTS08 Web Testing

Mickey Gousset shows you how to record a Web test using Visual Studio Team System 2008.

Visual Studio Team System 2008 (both the Testing edition and the Team Suite edition) have a type of test referred to as a Web test. These Web tests are used to test the functionality of Web applications, and are also designed to be used to load test Web applications.

How Team System Web Tests Work
A Team System Web test consists of a series of HTTP requests that are recorded using the Web Test Recorder in a browser. Web testing in Visual Studio Team System works at the protocol level, by issuing HTTP requests directly to the Web server, then receiving a response directly back. The Web test does not actually run in a browser. As such, Javascript is not run as part of the Web test. However, the results of any Javascript that were run while the test was recorded will be used when the test is played back. There are also multiple options that can be used to simulate Javascript actions at runtime, including Web test plug- ins, Web test request plug-ins, and extraction rules.

Recording a Web Test
Before a Web test can be recorded, there must be a Visual Studio Test Project in which to store the test. To create a new test project, open Visual Studio, and select File -> New -> Project from the main menu. In the New Project dialog, under Visual C#, select Test Project. Finish filling out the dialog and click OK to create the test project. Figure 1 shows an example of the New Project dialog window:



[Click on image for larger view.]
Figure 1.

The next step is to create a new Web test. This will automatically launch Internet Explorer and activate an integrated Web Test Recorder. This recorder will record every action performed in the browser.

To begin, right-click on the test project created previously and select Add -> New Test from the context menu. Select the Web Test template, and name the test MySimpleWebTest.webtest, then click the OK button. Internet Explorer will open, with the integrated Web Test Recorder.

To start the Web test recording, simply navigate to a site. In Figure 3, we have navigated to the main site of our application. Notice in the Web Test Recorder, it is tracking every request made.

Using the Web Test Recorder, you have the option to pause the test, stop the test, or delete what has been recorded and start over. You also have the ability to add comments to the Web test. It is considered a good practice to add comments after each request. This makes it easier, in the future, when looking back at this Web test, to understand its purpose.

Continue moving through the Web application until the test case being worked on has been recorded. Figure 2 shows a finished recording, where we are testing the login, search, and view functionality of this Web application. Comments have been added to the Web test recording to make it easier to understand what each request is doing.



[Click on image for larger view.]
Figure 2.

Figure 3 shows a drill-down into the requests in the recording. Notice how all the form post parameters and query string parameters are captured for use in future playback. Once you are finished recording the Web test, click the Stop button on the Web test recorder and return to Visual Studio.



[Click on image for larger view.]
Figure 3.

Back in Visual Studio, the recorded Web test appears as a series of requests, as shown in Figure 4.



[Click on image for larger view.]
Figure 4.

Conclusion
In this column, part one of a series, we have looked at how to record a Web test using Visual Studio Team System, Internet Explorer and the Web Test Recorder. In part two, we will look at the Web test in Visual studio in more detail, and show how to run the recorded Web test.

About the Author

Mickey Gousset spends his days as a principal consultant for Infront Consulting Group. Gousset is lead author of "Professional Application Lifecycle Management with Visual Studio 2012" (Wrox, 2012) and frequents the speaker circuit singing the praises of ALM and DevOps. He also blogs at ALM Rocks!. Gousset is one of the original Team System/ALM MVPs and has held the award since 2005.

comments powered by Disqus

Reader Comments:

Wed, Dec 7, 2011 Nikhil Mumbai

I recorded the web application for web test but no script or request made to application is generated. What may be the issue?

Tue, Oct 26, 2010 Sudhir

while trying to add new web test, i do the following steps:To begin, right-click on the test project created previously and select Add -> New Test from the context menu. Select the Web Test template but no web test template is displayed even though article is published under VSTS2008 heading. could you clear please...

Sat, Oct 2, 2010 abhijit kolkata

while trying to add new web test, i do the following steps:To begin, right-click on the test project created previously and select Add -> New Test from the context menu. Select the Web Test template but no web test template is displayed any idea, i worked on VSTS 2010 Premium

Thu, Sep 9, 2010 smith

For VS 2010 premium ,the webtest doesn't work.With ultimate version we can find webtest template.Also webtesst plugin 2.0 thats found in codeplex site can be downloaded and can work with Vs 2010 ultimate.

Wed, Jun 16, 2010 Johnny Lebanon

while trying to add new web test, i do the following steps:To begin, right-click on the test project created previously and select Add -> New Test from the context menu. Select the Web Test template but no web test template is displayed any idea, i worked on VSTS 2010

Thu, Mar 18, 2010

Whe running a test on a page that does a request on http://www.google-analytics.com/ga.js, I get Request failed: No connection could be made because the target machine actively refused it xx.xxx.xxx.xxx:80

Sat, Mar 13, 2010 Nivethitha Bangalore

When I am recording a CRM application the Form Post Parameters are not getting recorded.
Please let me know how to do it.

Fri, Feb 5, 2010 houssam France

Hello, i did all the steps which noticited in this document and i still have the same problem with the test web recorder, when i navigate to www.google.com the recorder record very good but when i navigate to my site http://localhost:100/mysite/Default.aspx the web test recorder disable and i can't record what happen in my site ..

Add Your Comments Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above

.NET Insight

Sign up for our newsletter.

I agree to this site's Privacy Policy.