views:

348

answers:

2

I have a program that needs to run as a separate NT user to connect to a SQL Server databases. For running a program itself, this isn't a big deal as I can just right click on it in windows explorer and select run as. Is there any way to run my tests as a different user as well? (it would be nice if I could do so in Visual Studio)

Update: As of right now, I'm just unit testing using the integrated unit testing framework in Visual Studio 2008 Pro. I'm running them just using the "run all tests in current solution" menu option.

+1  A: 

There's a command line program "runas", which you can use to run your tests as long as they are standalone programs. I'm not sure how exactly to integreate it with your tests, as I may need a bit more information on how you run them.

This method will ask you to enter your password.

Raymond Martineau
I added some more info about how I'm running them.
Jason Baker
+1  A: 

You could absract and mock the mechanism that determines the current user. This would allow you test as anyone.

Jamal Hansen