Site Loader
Auckland, New Zealand
So far, we have seen running test via Visual Studio 2010, in this post we are going to see how we can execute a test via command prompt. The reason for running a coded UI test in command prompt are many, there might be situations where you need to execute test
  • Where only Test Agent is installed not visual studio
  • Run specific set of test via another process like batch file or powershell commandlet
  • Run via another tool
Execution of test via command prompt can be achieved by what is called MSTest.exe, which comes along with Visual Studio 2010 and we don’t have to make any separate installation or download. Let’s see how we can run the test via command prompt without wasting any further time. Step 1 Open the command prompt and navigate to your visual studio 2010 installation directory which has MSTest.exe. I have installed my visual studio 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0. The MSTest.exe can be found under C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE. cmd Step 2 Now type the following command for MSTest.exe with following switches (Arguments)
 MSTest /testcontainer:"Test project DLL" /test:"Login_Application"
As you could see above MSTest – Is the MSTest.exe which executes the test /testcontainer: – Usually the test project DLL file which are located in bin folder of project /test: – Test method which we are going to execute This will automatically execute the test. Further settings are listed here /testsettings: – Settings file of test, which can be Local.settings We can also run vsmdi file with the help of switch called /testcategory: For more details visit here http://msdn.microsoft.com/en-us/library/ms182489.aspx Thats it !!! Thanks, Karthik KK  

Post Author: Karthik kk

11 Replies to “Running Coded UI test via Command prompt”

  1. Hi Karthik,
    I have been referring your blogs and found them very helpful. Can you please post regarding executing the Visual studio 2012 scripts through command prompt.

    Regards,
    Kishor Gaur

  2. Hi,
    When i run my powershell script to run codedui test on remote machine, i am getting the below error. Actually i have prepared a cmd file which starts execution.

    Error: Test host process exited unexpectedly.
    + CategoryInfo : NotSpecified: (Error: Test hos…d unexpectedly.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
    + PSComputerName : anoohya.qsidomain.net

    NotSpecified: (:) [], RemoteException
    Error: Failed to queue test run ‘xxxxx 2016-07-27 13:16:50’: Unable to start the agent process.
    NotSpecified: (:) [], RemoteException
    NotSpecified: (:) [], RemoteException

    1. You can run multiple tests within a same DLL, I guess the optimum case is all your test methods will sit in same DLL (for a single project within that solution).

      But you can do something like this as well

       mstest.exe /testcontainer:project1.test.dll /testcontainer:project2.tests.dll 

      Thanks,
      Karthik KK

  3. Hi Karthik,

    Your blog is really helpful.
    I am confused about a thing in CodedUI, can i create multiple test scripts?
    For eg, i want to create 10 different scripts corresponding to different test cases. Can i do that in Coded UI? What is the method for it?
    I want to run these test scripts independent of each other.


    Regards
    Ekvinder Singh

  4. Hi,

    I have a .sln file with multiple coded ui tests inside. Eg Forms.sln with 60 coded ui tests inside. I can run this Forms.sln file in Visual studio perfectly by hitting ‘run all’ and it runs all the 60 tests in sequence. How do I run this Forms.sln file from the command prompt? I have tried devenv, but as it contains coded ui tests, I get the error ‘cannot run as it is not a class library’. Have tried mstest, tcm and vstest as well. But they either want an exe file or a dll file to run. The Forms.sln folder does not have either. There must be a way of running it from the command prompt, but I have not been able to find information. Any details would be greatly appreciated

  5. how to run test scripts using Ms test command in case the framework is EasyRepo?
    EasyRepro is a framework launched by Microsoft for UI Automation for Dynamic CRM Application. solution contains 3 layer projects one contains API other contains browser and last one contains Test Scripts.
    from git Hub u can doanload this framework, create one trial CRM application and try to execute tests using Ms test all execution fails
    please suggest Urgent…

  6. Hi Karthik,
    How to run coded ui test scripts in parally in desktop . can you please suggest me

    thank you
    veerendra

  7. Hi Karthik,

    How are yo u? hope you are doing good.

    I am already user of many of your courses. Now planning for Coded UI course on udemy. Have small doubt? I need more videos on Windows driver automation also coded ui latest version videos. I heard support for coded ui is no more latest VS versions from microsoft. Is it correct?

    Please share the discount coupon for Coded UI course

    Thanks
    V

Leave a Reply to Russell Johnston Cancel reply

Your email address will not be published. Required fields are marked *