Azure DevOps, Scrum, & .NET Software Leadership and Consulting Services

Free course! Predicting the Future, Estimating, and Running Your Projects with Flow Metrics

Sample Custom Validation and Extraction Rules for Web Tests in Visual Studio Team System 2008


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

Downloads:

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.

image

Here’s an image of the Add Extraction Rule dialog with the custom rules are circled in red. 

image 

-Ben

 

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.

SUBSCRIBE TO THE BLOG


One response to “Sample Custom Validation and Extraction Rules for Web Tests in Visual Studio Team System 2008”

  1. Rick Avatar
    Rick

    Hi Benjamin,

    Your “Sample web app with web tests, custom web test rules, plus source code” solution has problem opening in my box(VSTS 2008/SQLEXPRESS 2005/XP PRO), will you mind email me with the instruction on how to do the initial setup/config, or any prerequirement notes can be really helpful to me:

    2 Projects unable to open properly: Com.Benday.WebTesting.Database & Com.Benday.WebTesting.WebUI

    Thanks a lot,
    -Rick

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.