我如何 运行 Visual Studio 作为特定用户在 vNext 构建中进行测试

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

我们的 VNext 构建是使用 tfs 2015 创建的。Visual Studio 测试步骤 运行 没问题,但对于某些应用程序,我们希望 运行 作为特定用户进行单元测试.

是否可以在 "Visual Studio Test" 步骤中执行此操作,或者我是否需要使用其他方法?

出自这篇文章:Test agent, Test Controller and MSTEST FAQ(第21题),应该也适用于VS测试。

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.

所以,我们在"Visual Studio Test"这一步不能指定用户,测试会运行代理,你可以尝试把代理服务账号改成用户的具体账号。或者使用特定帐户将新代理部署到 运行,参考:Running Unit Tests on different machine during TFS 2015 build