locked
Run coded ui test from WPF application RRS feed

  • Question

  • I want to run my coded ui test cases from a WPF application. However, when I initialize playback and call the test method, I am getting an error that the TestContext is NULL. Could anyone pls suggest if execution of coded ui test via WPF application is possible? Also, how can I access the TestContext in this approach as the test cases are data driven and I need to access TestContext.

    Thanks.

    Thursday, October 29, 2015 8:29 AM

Answers

  • I still don't think there will be anything wpf specific to this and it's rather more about how coded ui tests work.

    They run within mstest. The expectation being that you're going to run tests in visual studio or on a CI server rather than from a UI.

    If you want to initiate them from an app then you need a dll with your tests in it and use process.start to present that dll to mstest.

    You can see some more about that here:

    https://social.msdn.microsoft.com/Forums/en-US/133cc2fc-78bf-477a-9ebb-4cd127846d85/running-mstest-using-c-processstart?forum=vststest

     
    
    
    
    Hi
    
     I am able to run the mstest using
    
    
    Process myProcess = new Process();
    ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings["mstest"], "/testcontainer:" + testName + " /runconfig:\"C:\\MySecuredBrowser\\localtestrun.testrunconfig\" /nologo");
    
    myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    myProcess.StartInfo = myProcessStartInfo;
    myProcess.Start();
    

    and here:

    http://stackoverflow.com/questions/13482796/executing-coded-ui-test-from-a-standalone-application

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

    You would then have to read the trx file if you wanted to present any results.


    Hope that helps.

    Technet articles: WPF: MVVM Step 1; All my Technet Articles

    Thursday, October 29, 2015 3:00 PM

All replies

  • I assume you are running coded ui tests ON a wpf application rather than from one.

    Giving coded ui tests to an end user seems a bit unlikely.

    This article here includes a basic introductory sort of example of running some tests and manipulates the testContext:

    http://blogs.msdn.com/b/geoffgr/archive/2014/08/05/adding-timers-to-coded-ui-tests-running-in-load-tests.aspx

    By the way.

    Running coded ui tests on an application isn't really a wpf question, it's a coded ui question.

    Please ask any further coded ui test questions here:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=vsautotest


    Hope that helps.

    Technet articles: WPF: MVVM Step 1; All my Technet Articles


    • Edited by Andy ONeill Thursday, October 29, 2015 9:29 AM
    Thursday, October 29, 2015 9:28 AM
  • Appreciate your reply. However, the requirement is to run/inititate the coded ui test cases from WPF application.
    Thursday, October 29, 2015 2:42 PM
  • I still don't think there will be anything wpf specific to this and it's rather more about how coded ui tests work.

    They run within mstest. The expectation being that you're going to run tests in visual studio or on a CI server rather than from a UI.

    If you want to initiate them from an app then you need a dll with your tests in it and use process.start to present that dll to mstest.

    You can see some more about that here:

    https://social.msdn.microsoft.com/Forums/en-US/133cc2fc-78bf-477a-9ebb-4cd127846d85/running-mstest-using-c-processstart?forum=vststest

     
    
    
    
    Hi
    
     I am able to run the mstest using
    
    
    Process myProcess = new Process();
    ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings["mstest"], "/testcontainer:" + testName + " /runconfig:\"C:\\MySecuredBrowser\\localtestrun.testrunconfig\" /nologo");
    
    myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    myProcess.StartInfo = myProcessStartInfo;
    myProcess.Start();
    

    and here:

    http://stackoverflow.com/questions/13482796/executing-coded-ui-test-from-a-standalone-application

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

    You would then have to read the trx file if you wanted to present any results.


    Hope that helps.

    Technet articles: WPF: MVVM Step 1; All my Technet Articles

    Thursday, October 29, 2015 3:00 PM
  • Did it work??

    I need to find a control from a WPF Application instead of executing tests?

    Thursday, September 22, 2016 6:15 AM