简体   繁体   English

如何使用Jenkins运行编码的UI测试?

[英]How do I run a coded UI Test using Jenkins?

For the past few days I have been cracking my head trying to figure out how I can run a Coded UI Test directly from a Jenkins Job. 在过去的几天里,我一直在努力思考如何直接从Jenkins Job中运行编码的UI测试。 Since i am quite new to jenkins. 由于我对詹金斯很陌生。 I plan on running the jenkins job using the test controller and agent both installed in the same machine as the local VS project repository where my project is stored. 我计划使用测试控制器和代理来运行jenkins作业,它们都存储我的项目的本地VS项目存储库安装在同一台计算机上

My goal is to get a Jenkins Job to run a coded ui test which interacts directly with my desktop. 我的目标是得到一个Jenkins Job来运行与我的桌面直接交互的编码ui测试。

Specification used for the test: 测试规格:

  1. VS Enterprise 2015
  2. Agents for MS 2013
  3. Jenkins 1.69

What I have Done So far is Below (this is the batch command that i run from Jenkins, which i copied from How to run Coded UI test file from Visual Studio command prompt using batch file? ) which works Successfully when run through CMD : 到目前为止,我所做的事情是下面的内容(这是我从Jenkins运行的批处理命令,该命令已从如何使用批处理文件从Visual Studio命令提示符下的“如何运行已编码的UI测试文件”中复制 ),该命令在通过CMD运行时成功运行:

@echo off
:: Running tests without VS Enterprise is possible if you install the Test Agent package: https://msdn.microsoft.com/en-us/library/dd648127.aspx

set test_runner="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
set test_dlls="C:\Location\Compiled\Tests\Project.CodedUI.Test.dll"

:: If tests is set then only these comma separate test cases are run
:: set tests="Test1,Test2"
set tests=""

if %tests% == "" (
     %test_runner% %test_dlls% > CodedUITestResults.txt
) else (
     %test_runner% %test_dlls% /tests:%tests%
)
pause

I am using my local repository (Not TFS or GIT since that is not the requirement) on my windows machine which is when running the script executes the coded ui test successfully. 我在Windows机器上使用本地存储库(不是TFS或GIT,因为这不是必需的),这是在运行脚本时成功执行编码的ui测试的。

However, when it comes to replicating the steps in jenkins I get this error (even after configuring the test controller using VS in a .settings file):/ 但是,在复制jenkins中的步骤时,我会收到此错误(即使在.settings文件中使用VS配置测试控制器之后):/

Error calling Initialization method for test class CodedUITest: 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. 为测试类CodedUITest调用初始化方法时出错:Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException:若要运行与桌面交互的测试,必须将测试代理设置为作为交互式进程运行。 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=159018 ) / 有关更多信息,请参阅“如何:设置测试代理以运行与桌面交互的测试”( http://go.microsoft.com/fwlink/?LinkId=159018)/

My Questions are: 我的问题是:

  • Why does my tests keep giving me this error despite the fact that my test agent has been set as interactive? 尽管我的测试代理已设置为交互式,但为什么我的测试仍会给我这个错误?
  • Also, how would I get it to run from Jenkins, in order for it to interact with desktop directly as an interactive process? 另外,如何让它从Jenkins运行,以使其作为交互过程直接与桌面交互?

MS test controllers and agents are quite buggy and don't have proper documentation. MS测试控制器和代理存在很多故障,并且没有适当的文档。 This is why my company developed a free and open-source alternative. 这就是为什么我的公司开发了一种免费的开源替代方案。 You can find it here- http://meissarunner.com There is a link to documentation where it will be quite easy for you to setup. 你可以找到它这里- http://meissarunner.com还有就是文档的链接它会很容易为你设置。 Since, it uses .NET core you need to specify an additional parameter mentioning the .net Framework version you use --nativeRunnerArguments="--framework=net462" you can find a complete list of the frameworks here- https://docs.microsoft.com/en-us/dotnet/standard/frameworks If you have any problems drop me a line. 由于它使用.NET核心,因此您需要指定一个附加参数,以提及您使用的.net Framework版本--nativeRunnerArguments =“-framework = net462”,您可以在此处找到框架的完整列表-https :// docs。 microsoft.com/zh-cn/dotnet/standard/frameworks如果您有任何问题,请给我写信。

Start Meissa in server mode: 在服务器模式下启动Meissa:

meissa.exe initServer

Then start an agent: 然后启动一个代理:

meissa.exe testAgent --testAgentTag="APIAgent" --testServerUrl="http://IPServerMachine:5000"

In Jenkins job start the runner: 在詹金斯工作中,开始跑步:

meissa.exe runner --resultsFilePath="pathToResults\result.trx" --outputFilesLocation="pathToBuildedFiles" 
--agentTag="API" --testTechnology="MSTestCore" 
--testLibraryPath="pathToBuildedFiles\SampleTestProj.dll"

This is a little late but to make the agent interact with the desktop all you need to do is on the setup of the agent check the checkbox for run as I interactive process. 这有点晚了,但是要使代理与桌面进行交互,您需要做的就是在代理的设置上选中“以交互方式运行”复选框。 You shouldn't need master and agent if it's all on the same box either. 如果它们都在同一框中,则您不需要主服务器和代理。 I think you can change the jenkins service to also interact with the desktop. 我认为您可以更改jenkins服务以与桌面进行交互。 Hopefully this helps somebody. 希望这对某人有帮助。 Agents and master works but I'll definitely check out meissarunner and see if it's better. 特工和大师的作品,但我一定会去看看meissarunner的,看看是否更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM