New Features in Visual Studio Team System 2010 (VSTS2010) Web Tests

June 27, 2009

I’ve been starting to research Visual Studio Team System 2010 (VSTS2010) and Team Foundation Server 2010 (TFS2010) so that I can update the training materials for my class.  Part of this process is going through the features that are in VSTS2008 and finding the places that they are different.

Last week, I was helping a client with some problems they were having with VSTS2008 Web Tests and Load Tests so that inspired me to look at web testing in VSTS2010.  Not surprisingly, there are some cool new features.

New Request Types

One of the limitations of VSTS2008 Web Tests has been the difficultly changing the flow of your running web tests based on conditional logic.  If you needed to do this as part of your 2008 web tests, your only option was to go with “coded” web tests and then hack the generated code to do what you wanted.

VSTS2010 Web Tests introduce two new “request” operations that make this much more easy: Conditional and Loop.

NewRequestTypes

Conditional is roughly equivalent to an “if” statement in C# and a Loop is roughly equivalent to a C# “while”.

AddConditionalRule

For both the Loop and Conditional, you specify the first and last item in the condition/loop and this sets up the steps that belong to the conditional/loop. From there you’ll need to create “rules” which tell the web test runner what to do and what to check – basically, these rules define the decision logic.  The out-of-the-box rules for Conditionals are:

  • Context Parameter Existence
  • Cookie Existence
  • Cookie Value Comparison
  • Last Request Outcome
  • Last Response Code
  • Numerical Comparison
  • Probability Rule
  • String Comparison

ConditionTypesInALoop

The out-of-the-box rules for Loops are similar to the Conditionals except that “Last Response Outcome” and “Last Response Code” are removed and “For Loop” and “Counting Loop” are added.

Here’s a screenshot of what a completed Conditional looks like:

ConditionSample

A nice added feature is that you can nest loops and conditions within other loops and conditions so that you can build up some pretty complicated logic.

AddItemsToCondition

Refactoring

Another new feature is the ability to refactor your recorded web tests.  In VSTS2008, if you wanted to take steps from an existing web test and put them into another test so that you could re-use them, you had to either edit the underlying XML for the *.webtest file or re-record those steps of the test.  With VSTS2010, you can right-click your web test and then choose “Extract Web Test…”

ExtractWebTest

Then from the Extract Web Test dialog, you tell it what you want to name the extracted test and specify the start and ending steps you want to extract.

ExtractWebTest_dialog

New Validation & Extraction Rules

If you’re writing an ASP.NET application, you’re probably going to use a Label control or a list control (DropDownList, RadioButtonList, ListBox, etc) now and again.  That’s actually kind of an understatement – you’re going to use those controls all the time and, if you’re web testing, you’ll need to validate them.  In VSTS2008, if you wanted to Validate or Extract one of those controls, you had to write a custom Validation or Extraction Rule.  Writing a custom rule isn’t all that hard but not being able to work with those common web control types out-of-the box was definitely a hole in the product.

Well, this has been fixed in VSTS2010.  (Yay!)  Now we’ll have two new Validation rules: Tag Inner Text and Selected Option.  Tag Inner Text allows you to get at tags (or any tag that you can match with attributes) and Selected Option allows you to validate List controls.  Both of these rules also have corresponding Extraction Rules that allow you to not just check if a value is correct on your page but also extract the values so that you can use them in subsequent requests, Loops, and Conditionals via test context variables.

AddValidationRule

-Ben

-- Looking for help adopting Visual Studio Team System & Team Foundation Server?  Problems installing?  Need training?  Want someone to coach your team to make sure you’re getting the most out of VSTS?  Starting to think about your VSTS2010/TFS2010 upgrade strategy?  Drop us a line via http://www.benday.com or http://blog.benday.com/contact.aspx

Tags: asp-net tfs