错误 "you must set up the test agent to run as an interactive process" 而 运行 编码 UI 来自 TFS 2015 构建过程的测试

Error "you must set up the test agent to run as an interactive process" while running Coded UI Test from TFS 2015 Build process

当我尝试使用 Team 运行 使用一种测试方法(验证 Windows 计算器应用程序的 "add" 功能)的简单编码 UI 测试项目时Foundation Server 2015(更新 4),我在测试执行步骤中收到以下错误 -

Error calling Initialization method for test class CodedUITestProject1.CodedUITest1: 
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To run tests that interact with the desktop, you must set up the test agent to run as an interactive process. For more information, see "How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop" (http://go.microsoft.com/fwlink/?LinkId=255012)

    If you are running the tests as part of your team build, you must also set up the build agent to run as an interactive process. For more information, see "How to: Configure and Run Scheduled Tests After Building Your Application" (http://go.microsoft.com/fwlink/?LinkId=254735)

    Stack Trace:

    at Microsoft.VisualStudio.TestTools.UITesting.Playback.Initialize()
    at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestExtensionExecution.BeforeTestInitialize(Object sender, BeforeTestInitializeEventArgs e)
    at Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestExecution.RaiseBeforeTestInitialize(BeforeTestInitializeEventArgs args)
    at Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestExecuter.RunInitializeMethod()

设置/环境详细信息: OS:Windows Server 2012 Standard(64 位 OS,基于 x64 的处理器) VS:Visual Studio Enterprise 2015 with Update 3 TFS:带有更新 4 的 Team Foundation Server 2015

构建定义(构建步骤)[不是 XAML 定义]:

运行 使用的设置文件:

<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="TestSettings1" id="bd8c898e-4b22-407c-bc02-0861123a1dbd" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
    <Description>These are default test settings for a local test run.</Description>
    <Execution>
        <TestTypeSpecific>
            <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
                <AssemblyResolution>
                    <TestDirectory useLoadContext="true" />
                </AssemblyResolution>
            </UnitTestRunConfig>
            <WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
                <Browser name="Internet Explorer 9.0" MaxConnections="6">
                    <Headers>
                        <Header name="User-Agent" value="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" />
                        <Header name="Accept" value="*/*" />
                        <Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
                        <Header name="Accept-Encoding" value="GZIP" />
                    </Headers>
                </Browser>
            </WebTestRunConfiguration>
        </TestTypeSpecific>
        <AgentRule name="LocalMachineDefaultRole">
        </AgentRule>
    </Execution>
    <Properties>
        <Property name="TestSettingsUIType" value="UnitTest" />
    </Properties>
</TestSettings>

我是否遗漏了上述任何步骤?请帮我解决构建失败的问题。

提前致谢!

此致,

阿彦

您使用了错误的任务。您需要使用 Run Functional Tests 而不是 Visual Studio 测试。

Typical scenarios include:

  • Tests that require additional installations on the test machines, such as different browsers for Selenium tests
  • Coded UI tests
  • Tests that require a specific operating system configuration
  • To execute a large number of unit tests more quickly by using multiple test machines

有关任务的更多信息,请参阅此博客:Running Automated Test on agent machine using vNext Build

除了 运行 编码 UI 测试之外,您还必须将测试代理配置为 与桌面交互 并构建代理 运行宁作为交互模式。