How can I run Visual Studio tests in a vNext build as a specific user

201 views Asked by At

Our VNext builds are created using tfs 2015. The Visual Studio Test step is running fine, but for some applications we want to run the unit tests as a specific user.

Is it possible to do this in the "Visual Studio Test" step, or do I need to use a different approach?

1

There are 1 answers

1
Andy Li-MSFT On BEST ANSWER

From this article: Test agent, Test Controller and MSTEST FAQ (Qustion 21), it should be also applied to VS test.

Will Test Agents allow you to impersonate another user? Or does the Test Agent always kick of tests as the user its configured start up as?

There is no built in support for impersonation, so by default tests run under the identity of the test agent. If this is something you really need, you could write a unit test extension that does the impersonation for you.

So, we can not specify the user in the "Visual Studio Test" step, the test will running with the agent, you can try to change the agent service account to the specific account of the user. Or deploy a new agent to run with the specific account, Reference : Running Unit Tests on different machine during TFS 2015 build