运行 功能测试任务失败并出现错误 "The agent process was stopped while the test was running"

Run Functional Tests task fails with error "The agent process was stopped while the test was running"

使用 运行 功能任务执行的编码 UI 测试用例退出时出现以下错误消息:“代理进程在测试 运行ning 时停止。”这些测试用例之前执行成功,错误描述不明确,进一步排查并解决问题。您能否分享一些有关根本原因和可能的解决方案的信息。提前致谢。

错误信息:

[error]System.Exception: 测试运行中的一些测试没有通过,任务失败。

环境详细信息: TFS 本地,TFS 2017 15.112.26307.0 (Tfs2017.Update1)

构建代理:私有,OS:Windows Server 2012 R2,构建代理版本:2.112.0

测试代理:私人,OS:Windows 10

测试部署任务版本:vstf_testagent.exe版本14.0.23107.10

根据错误消息“Some tests in the test run did not pass, failing the task.”,在您的测试日志中,您应该会看到如下内容:

Test run '5262' is in 'InProgress' state.
2017-03-22T09:04:32.3083813Z DistributedTests: Please use this link to analyze the test run : xxxx

您可以导航到测试中心中的测试运行以获取更多信息以进行进一步的故障排除。

根本原因应该是:

Automation engine is unable to playback the test because it is not able to interact with the desktop. This could happen if the computer running the test is locked or it’s remote session window is minimized.

因此,您可以检查测试是否适用于打开的远程桌面会话,如果有效,则应该正是问题所在。

解法:

要解决此问题并获得更好的体验,您可以安装 Autologon 工具,

这会自动登录服务器并创建交互式桌面。但是你不需要远程桌面什么的。

安装自动登录工具后,配置该工具以使用该帐户进行运行 测试,并重新启动服务器。然后再试一次。

参考这篇文章:Run Functional (Coded) UI Tests in your VSTS Release Pipeline