Web Test Client in Visual Studio 2005 Team Test

Posted Monday, June 20, 2005 9:08 AM by C-Dog's .NET Tip of the Day
One of the best new features in Visual Studio 2005 is the Web Test client.  This client allows you to record test scripts using Internet Explorer and then customize them with code.  You can execute the tests with any kind of browser but you can only record them with the IE plugin.  To create a new test project, look underneath test in the C# language group (VB for Marcus) in the new project wizard.
Once you have a new project stated click the Record New Test button.  This will launch a browser.  Click the record button and then go to the pages that you want to test (you can go to multiple pages).  Once you are finished recording, click stop and the data will be brought into Visual Studio.
The key thing to note is that you can test any kind of web site using a Web Test ASP.NET 2.0, ASP.NET 1.1, classic ASP, PHP, Java, or whatever.  If you are testing an ASP.NET site, the client automatically supports the parsing out of the viewstate hidden fields so that the sessions will remain unique when it is testing.
The Web Test client supports a lot of customization out of the box even without code.  You can post custom headers, files, and querystring or post parameters. 
To actually test that an expected result is present, simply add a Validation Rule.  You can add a validation rule to any step of the process and you can add as many as you want.  There are four types of Validation Rules, ValidationRuleFindText, ValidationRuleRequestTime, ValidationRuleRequiredAttributeValue, and ValidationRuleRequiredTag.  The only one I have really figured out how to use yet is ValidationRuleFindText (there is very little documentation on this right now). 
The ValidationRuleFindText simply confirms that a string exists somewhere in the text of a response.  You can configure it to ignore case and to pass or fail based on finding the text  For example, if you want to look for an error on your page, set PassIfTextFound to false and then set the FindText property to the text of your error.
Tomorrow I will discuss how you can customize these tests with code.  For something like this it is better to see it than to read about it, so I will most likely be giving a demo on it soon.

Read the complete post at http://www.dotnettipoftheday.com/blog.aspx?id=109