Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing coded UI test from a standalone application

I found several blog posts about how to execute code UI tests using mstest utility, but I need to execute them from my C# application. I tried the simplest thing: I created a console application, added references to

  • Microsoft.VisualStudio.TestTools.UITest.Logging.dll
  • Microsoft.VisualStudio.TestTools.UITest.Playback.dll
  • Microsoft.VisualStudio.TestTools.UITesting.dll

and I tried calling UI test method from my application. I got the following error:

The following is not a valid technology name: MSAA. To search for a control, you must specify a valid technology name.

I tried referencing other assemblies which are related to UI testing, but the error stays the same. Maybe there's something that I should add to App.config to be able to run the tests?

like image 229
Max Avatar asked Nov 20 '12 21:11

Max


3 Answers

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"
like image 198
S.Roshanth Avatar answered Oct 20 '22 02:10

S.Roshanth


You need to call Playback.Initialize() before you execute the coded UI part, and then Playback.Cleanup() after.

http://social.msdn.microsoft.com/forums/wpapps/zh-cn/914e0ecb-6917-43ff-baf6-f30acc6469d3/unable-to-run-a-coded-ui-test-method-when-called-from-a-console-application-project-in-vs2012

http://blogs.microsoft.co.il/blogs/shair/archive/2010/07/15/running-codedui-test-from-another-application.aspx

like image 32
Mitchel Avatar answered Oct 20 '22 03:10

Mitchel


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.

like image 1
AlignedDev Avatar answered Oct 20 '22 02:10

AlignedDev