If you haven’t seen Web Tests in Visual Studio 2008 Team Suite and Tester Edition (aka. Visual Studio Team System), you really should do yourself a favor and take a look. They allow you to write and record unit tests that will exercise and validate a running web application or web site.
The basic idea is that you record a path though an ASP.NET application and the web test recorder records the requests and responses to/from the server. Once you have the basic recorded test, you can then customize it to send different data to vary your test and also add validation and extraction rules to check that you’re getting the response you expect from the application.
The out-of-the-box validation and extraction rules are pretty good but are really just the start of what you’ll need to validate your running app. If you’re going to invest time in creating web tests, you’ll definitely need rules other than what comes with VSTS.
Here are some of the custom validation and extraction rules that I’ve written and use regularly:
- Validate ASP.NET Label Value
- Extract ASP.NET Label Value
- Validate ASP.NET GridView Row Count
- Extract ASP.NET GridView Row Count
- Text Exists Inside of HTML Tag
- Custom web test rule binaries
- Sample web app with web tests, custom web test rules, plus source code
To use the rules in your VSTS Web Tests, download the binaries, and add references from your VSTS Unit Test project to both of the DLLs in the zip: HtmlAgilityPack.dll and Com.Benday.WebTesting.WebTestRules.dll. Once you’ve added the reference, these rules should show up in the Add Validation Rule and Add Extraction Rule dialogs.
Here’s an image of the Add Validation Rule dialog with the custom rules are circled in red.
Here’s an image of the Add Extraction Rule dialog with the custom rules are circled in red.
If you’re looking for help installing or configuring Team Foundation Server or want guidance on using and adopting Visual Studio Team System, please contact me via http://www.benday.com.