How do I run Unit Test in VS as a different user?

I am a contractor doing some unit tests that use Windows Authentication to get to a test server on a different domain. I ran my tests on my clients VM and everything works fine since I am on their network and using my login credentials to my domain to run the unit tests. Unfortunately the VM is very slow (it took 30 minutes to reboot the server and 14 design solutions for me) and I decided to try VS on my laptop. I was able to get it to build everything fine, but when I go to run my unit tests it fails when it tries to access the test server, since I am running myself on my laptop which is not on their domain.

Is there a way to run unit tests as a different user?

I tried to use C: \ Windows \ System32 \ runas.exe / netonly / user: theirDomain \ uid "C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ devenv.exe" to run tests, but this doesn't work (I'm guessing because the unit tests actually works like QTAgent32.exe that it doesn't work). I was able to use the same command for SQL Server Manager to connect to their SQL Server.

Another option might be to figure out a way to trust my user credentials on my domain on my laptop, but that doesn't work either ...

+3


source to share


2 answers


You can run unit tests directly using the mstest.exe command line application. This is what VS does under the hood. Combined with runas.exe, I think this should completely solve your problem.

Link for mstest.exe: http://msdn.microsoft.com/en-us/library/ms182489(v=vs.80).aspx



Edit: I'd just like to say that in the interest of efficiency, I think the ideal solution here would be for their sys admins to create a domain account for you.

+1


source


If you have a domain account - you can connect a VPN connection or add your laptop to your domain.



0


source







All Articles