Powerd by dasBlog RSS 2.0
 Monday, June 23, 2008

This one took me a little longer then I figured. Maybe I’m just trying to do stuff the wrong way, but I don’t know, I feel like my use case is correct.

What am I talking about anyway? I am talking about creating a set of web tests in Visual Studio Test Edition (well Team Suite) that I can actually use in a real world situation (i.e. Have tests that work on a dev, staging and production server). The problem is/was, hard coded URLs for my dev server, which ultimately would have to be changed to point at staging and production.

Before proceeding, let me spell out what I’m trying to do (use case):

  • Use the VS GUI to create and most likely run my tests
  • Single place to store the web server, and other settings that I can use for all my tests

At first, I thought this was going to be a very easy change, as there is a “Parameterize Web Servers” option when you right click on the root node of your web test. This creates a context variable, which I thought was cool, until I realized it was on a test by test basis, not project. I guess I was looking for a project wide context parameters file, but couldn’t find one.

I did some searching and supposedly you can set an environmental (yes, from a command prompt) variable named Test.<ContextParameter>, however I was unable to get this to work. I think this might only work when invoking mstest from the command line which makes some sense, but kind of throws a wrench in the works. While this would be perfectly acceptable for a un-attended build server, what if I needed to point to a new dev server in the GUI?

I then moved to a XML data source with a single “line” of data":

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <Config>
   3:  <UrlRoot>http://dapltp101.dmz.pri</UrlRoot>
   4:  <LoginUserName>asalvo</LoginUserName>
   5:  <LoginPassword>123456</LoginPassword>
   6: </Config>

 

This worked pretty good, except that when selecting UrlRoot from the drop down list of available options, it replaced the entire URL, and not just the URLRoot. I do like how they made the property grid “strong typed” in that it gives you the fields you defined for your data source, but I didn’t want to replace my whole URL. Also, I could not edit the value after selecting my XML data source value.

Looking at the format of ContextProperties in values, as well as how the data source was referenced, I decided to try typing what I wanted in myself. I went to the URL value and replaced the URL root with the name my XML data element, and this worked.

For example, given:

Type this in the value field for your URL in the Request object on the test: {{ConfigXml.Config.UrlRoot}}/Location1

Like I said, that took me a little while longer then I would have thought. I should have went with my gut and tried that format soon after getting the regular XML data source to work.

I do have one last issue (well the fist of many I am sure), and that is, I have two URL’s when I really should only have one. When I hit the root of my website, I am redirected to a https:// URL, and that is treated differently. I’d like to capture the redirected URL and use that so I don’t have to maintain two values in my configuration file, but I’m just gonna roll with it for now.

Monday, June 23, 2008 9:14:44 PM UTC  #    Comments [0] - Trackback
Programming
Archive
<June 2008>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Adam Salvo
Sign In
Statistics
Total Posts: 160
This Year: 86
This Month: 2
This Week: 0
Comments: 9
Themes
All Content © 2008, Adam Salvo
DasBlog theme 'Business' created by Christoph De Baene (delarou)