I have a situation where I want to make the host name in the UrlToTestAttribute argument configurable. Obviously, it has to be a constant value for this to work. I created a class that has nothing but constant values that I use throughout my tests, that way when other team members grab the code they can change the values in one file to accomadate their setup/configuration.

I've tried to do this two ways.

1) Adding in the host name:

Code Snippet

[UrlToTest("http://" + URLConfig.Host + /CustomControlTest")]

Code Snippet

public class URLConfig


public const string Host = "localhost";


2) Putting the entire string into a const string, then using it as the argument

Code Snippet

public const string CustomControlTestUrl = "http://" + URLConfig.Host + "/CustomControlTest";


Both will compile file, however during runtime I get an exception. In the first case the error message is:

The URL to test 'http://" + URLConfig.Host + "/CustomControlTest' is invalid. Invalid URI: The hostname could not be parsed. "

I'd like to emphasis that this is not a compiler error, this is a runtime error. Does the test framework really read the source file to extract the value

I can even go as far as making CustomControlTestUrl = "http://localhost/CustomControlTest", and it will still fail.

Re: Visual Studio Team System - Testing UrlToTestAttribute Arguments

David Gorena Elizondo - MSFT


The issue that you are talking about is a known issue; we do not support that scenario because of design issues, which have implications on things such as performance in our first version. The only workaround is to use a string value instead of the constants


David Gorena Elizondo