UKVSTS Web Test Plug In

This assembly allows you to create scriptable parameters in your web tests. This extends the control you can have in your test without having to write your own test or request plugins.
ExampleParams.png
I have stolen the syntax that ASP/ASP.Net uses to mark up a script block. When the test client comes to make your request, the scripts will be evaluated at runtime and the result of the script will be passed as the parameter value.

You can also create scripted Context Parameters - useful if you want to evaluate something at the beginning of a test.
ContextParam.png

To use the ScriptableParameterPlugIn, follow these steps

1. Download and Run the MSI
2. In your web test project, add a reference to the UKVSTS.WebTestPlugins assembly. There are 2 versions of the plugin dll, one for VS 2005 and VS 2008 - Pick the dll for the version of Visual Studio you are running.
addref_2008.png
3. Click on the Set Web Test Plug In button on the test's toolbar
TestPlugin.png
4. In the Set Web Test Plug-in dialog, select the ScriptableParameterPlugIn
PlugIn.png
5. Click Ok
6. Start adding scriptable params to your test.

When creating scriptable parameters, you have 2 options:
1. Single Statement parameters have the format <%= expression %> Where expression is any C# statement that would eveluate to return an object.
examples are:
  • <%= DateTime.Now %> - for the current date and time
  • <%= DateTime.Now.ToString ("dd-MM-yyyy") %> - for the current date and time in the specified format
  • <%= Guid.NewGuid() %> - for a new GUID
2. Multiple Statements are where you need a little bit more freedom than one statement. In this type of parameter you will need to provide your own return statement and semicolons.
examples are:
  • <% return DateTime.Now; %>
  • <% if (Context.IsNewUser) { return Guid.NewGuid (); } else { return Context [["UserName"]] } %> - Ok, so you could have done that in one statement with a ? :, but I got stuck for an example :-)

Misc

  • You get access to the current WebTest, WebTestRequest and WebTestContext using the Test, Request and Context properties respectively.
  • The results of all scripted parameters will automatically get added to the current test context so you can use them in any validation rules of subsequent requests.
  • You can have more than one script block per parameter. This is probably most useful if you are doing testing of web services.
  • You can script the file name property for any file upload parameters

Last edited May 16, 2008 at 5:35 PM by NeilKidd, version 21

Comments

rdodier Aug 14, 2012 at 8:05 PM 
The directions for this mention a plug-in dll for vs2005 & vs2008. Is there a plug-in for vs2010 or is this functionality already built into vs2010? I'm looking to assign and use a parameter that gets the result of something like DateTime.Now.Add(2), so if there is a newer/better way to do this without the download I'd be interested in that as well.

PS - I saw that I can use a Coded test but prefer just defining this within a regular web test as a context paramter if possible (i.e. Parameter = <%= DateTime.Now.Add(2) %>.

rupakg Dec 6, 2007 at 5:57 PM 
Nice work. I have mentioned it in my blog post at http://developershelf.blogspot.com/2007/12/ieeee-ie-add-in-for-capturing-bug.html