从 TeamCity 启动 TestExecute

Start TestExecute from TeamCity

为了测试我们的桌面应用程序,我们使用 TestComplete/TestExecute。 我们有一个在管理机器上启动的主项目。 这个主项目不需要与桌面交互,它不是在测试我们的应用程序。

此项目将直接通过 TestExecute 在不同的 VM 上启动 Slave 远程项目(我们应用程序的实际 UI 测试需要桌面交互)。

我们目前正在将构建过程转移到 TeamCity。在这台管理机器上,我们有一个来自 TeamCity 的构建代理。构建代理 运行 作为具有系统帐户(而非本地系统帐户)的服务。

我们没有使用本地系统帐户(可以与桌面交互),因为我们需要一个域帐户来访问域资源。而且我们不想将 Agent 作为一个进程来启动,我们想让它保持在服务状态。

现在,我们无法直接从 TeamCity 启动 TestExecute,因为 TestExecute 需要交互式会话,而 Build Agent 的帐户无法与 Desktop 交互。 我们尝试使用脚本(从 TeamCity 执行)创建一个具有普通用户的 PSSession,该普通用户可以访问 Desktop 并从此 PSSession 启动 TestExecute。但这也不起作用。

这是我们在两种情况下(直接和通过 PSSession)遇到的例外情况:

Start-Process : This command cannot be run due to the error: This operation requires an interactive window station.
At line:3 char:9
+         Start-Process "D:\SmartBear\TestExecute 12\Bin\TestExecute.ex ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
     + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

有人有从 TeamCity 使用 TestExecute 开始测试的解决方案吗?正如我所说,这个项目不需要与桌面交互,它将启动 UI 直接通过TestExecute在不同的VM上进行测试。

或者域系统帐户(比如我们正在使用的帐户)是否可以与桌面交互?

您可以做的最简单的事情是 运行 来自 Team City 的主项目,主项目将在从机上调用 UI 测试。由于主项目不需要访问 UI 元素,因此 运行 在 non-UI 会话中使用它不会有任何问题。

在TestExecute的安装目录下,可以找到manifest文件 TCLauncher.exe.Manifest :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <!-- Here is the relevant part -->
        <requestedExecutionLevel level="asInvoker" uiAccess="true">
        </requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

您可以将 uiAccess 配置为 false。

如果你不使用TCLauncher,直接TestExecute.exe,还有一个Manifest文件,和<Security>相同的部分你可以配置。

您也可以指定级别,从 asInvokerhighestAvailable,但您可能会收到 UAC 的提示。