Geeks With Blogs
Mark Wiggins blog

  We have had a challenge to get TFS to record a test and replay it multiple times. I think the basics are easy but let me add a few more kinks.

  1.  Session variable in the URL
  2. A variable that is returned in the response query that changes at each post
  3. A SessionID for database connectivity, this variable is good throughout the entire session
  4. https/SSL

The 4th kink was easy enough we turned https off during the recording process. The session variable and SessionID were fairly easy. Create a class and write enough code to substring the variable out of the URL. Something like this:

string url = e.Response.ResponseUri.AbsoluteUri;

      int startwith = url.IndexOf("S(");

      int endwith = url.LastIndexOf("))");

      string formFieldValue = url.Substring(startwith + 2, endwith - startwith - 2);

      string val = e.Response.ResponseUri.Query.ToString();

 

 

Assign val to the property in the class that you will use and you are good to go. We were able to do that with both the SessionID and the Session variable. Now for the fun part. #2 – we call the variable “tm”. This system has a ASP.NET front end with middle tier logic that calls into Business Rules and the database and the back to the UI. Easy enough except a few things the “tm” controls which ruleset to call. The ruleset is unique to the dataset that the UI sent so each tm for each request will be different. The good thing is we found it in the “Last Response”.

 

this.LastResponse.ResponseUri.Query.Substring

 

We had to substring it out as well but that was easy.  Alright looks like we had the class built and we knew where to find our “tm” value. We are good to go.

 

A couple of problems exist using straight TFS recordings.  TFS does not record every GET and every POST, which means some of the details are left out. TFS does not record viewstate, so unless you have a pretty stateless environment without any post backs TFS will not handle the recording for you.

MS has a tool called Fiddler. Every developer should have this tool. I am not sure why Fiddler is a separate tool from TFS but it is nice. It records every POST and every GET. MS just released(about to – Beta is out) Fiddler 2 which records viewstate. The good thing about this tool is that you can save the test in many formats, one of them being a TFS test. So there you have it. We had a challenge and found ways to work through them. We did have to open a case with MS but they helped us a lot and we learned a bunch too.

 

Oh yea…

One last thing. If your site uses hidden fields, you will fail every time until you take the web.config and add this line.

<pages enableEventValidation="false" viewStateEncryptionMode ="Never" />

 

Now there are security risks so only use this in a test environment and not an environment exposed by the DMZ.

 

You can find more on this topic at

 

http://aspadvice.com/blogs/joteke/archive/2006/02/02/15011.aspx

 

So that is all for now. Have fun with your TFS testing.

Posted on Wednesday, June 27, 2007 1:04 AM | Back to top


Comments on this post: TFS Testing

# re: TFS Testing
Requesting Gravatar...
Clearly, you are the smartest man alive.
Left by Patrick Quilter on Jun 26, 2008 1:03 AM

Your comment:
 (will show your gravatar)


Copyright © Mark Wiggins | Powered by: GeeksWithBlogs.net