Executing coded UI test from a standalone application

≡放荡痞女 提交于 2019-11-27 09:19:47

I am executing the coded UI test with a bat file, you can simply copy the CUIT test .dll file to your application and call it by a bat file to execute. Even you can use Test Agents to run the Code UI Test from different machines, where you don't have Visual Studio.

my bat file looks like this:

Run All Test methods from DLL :


"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe" /testcontainer:"DLL_Location\CUIT_03.dll" /resultsfile:"ResultFile_Location\result.trx"

Run Single Test Method From DLL:


"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe" /testcontainer:"DLL_Location\CUIT_03.dll" /test:"TestMethodName" /resultsfile:"ResultFile_Location\result.trx"

I had a similar problem when running with MSTest in C#. I'm using Selenium, so I marked my base class with the [TestClass] attribute. I need CodedUI to test file uploading. When I changed it to [CodedUITest] it worked.

Will you solve your problem if you invoke MSTest from C#? If so, this MSDN post tells you how.

Otherwise, I would try to use a disassembler in MSTest to find out what it does and what references it uses. A quick look at it pointed me to Microsoft.VisualStudio.QualityTools.ExecutionCommon as well as a class called Executor in Microsoft.VisualStudio.QualityTools.CommandLine.

May I ask, why do you need to invoke a CUIT from C#?

I believe you're missing some references, try this blog, this are all the references you'll need:

c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\

Microsoft.VisualStudio.TestTools.UITesting.dll
Microsoft.VisualStudio.QualityTools.CodedUITestFramework.dll

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\image

Microsoft.VisualStudio.TestTools.UITest.CodeGeneration.dll
Microsoft.VisualStudio.TestTools.UITest.Framework.dll
Microsoft.VisualStudio.TestTools.UITest.Playback.dll

Try this blog: http://blogs.microsoft.co.il/shair/2010/07/15/running-codedui-test-from-another-application/

it lists all the referenecs you need (tried ot and it works for winforms (MSAA)).

Check that your application is running as 32 process , because coded UI does not work with 64 bit processes and cannot be consumed in them.

Hi Its working in my case: use below code==>

Playback.Initialize();
CockpitAutomate.CockpitAutomate c = new CockpitAutomate.CockpitAutomate();
c.RunCockpit();
Playback.Cleanup();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!