Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2010 Coded UI Test - Launch Referenced Application

Tags:

I'm using Visuial Studio's Coded UI Tests to run Automated UI tests on a WPF Application everytime a build runs on my TFS server. The problem I am running into is dynamically launching the executable based on the path where it was just built to, including the configuration(x86, x64).

Is there any way to get the path to an executable in a referenced project so that I can launch the application dynamically from my test project?

like image 528
Cory Avatar asked May 05 '10 21:05

Cory


People also ask

What is the difference between Coded UI and selenium?

Selenium IDE supports XML data sources. Coded UI Test supports any data source supported by.NET framework, which can come in the form of a. CSV file, XML file. It can also support any other data source like SQL Server table, Access table etc.

Why is coded UI deprecated?

Microsoft decided to deprecate Coded UI because the open-source UI testing tools such as Selenium and Appium have gained momentum in recent years, have a strong community backing, and are now pretty much industry standards.


2 Answers

MSTest:

  1. Open your .testsettings file and check the "Enable Deployment" under the deployment section.
  2. In your test project right-click and select Add Existing Item.
  3. Browse to the build location of your application to test.
  4. Find your executable and select "Add as link" (make sure you either include all of your apps dependent DLL's if they are not already referenced by your test project.)
  5. Right click the link to the executable and select "Copy Always" (this will copy a new version of the .exe to your tests bin directory when it is built)
  6. In your [TestInitialize] add the following to launch your app:

    _yourApp = ApplicationUnderTest.Launch(Path.Combine(Directory.GetCurrentDirectory(), "yourexecutablename.exe"));
  7. In your [TestCleanup] you add the following:

    _yourApp.Close();

NUnit: (you will need to reference and use Microsoft.VisualStudio.TestTools.UITesting)

  1. In your test project right-click and select Add Existing Item.
  2. Browse to the build location of your application to test.
  3. Find your executable and select "Add as link" (make sure you either include all of your apps dependent DLL's if they are not already referenced by your test project.)
  4. Right click the link to the executable and select "Copy Always" (this will copy a new version of the .exe to your tests bin directory when it is built)
  5. In your [Setup] add the following to launch your app:

    _yourApp = ApplicationUnderTest.Launch("yourexecutablename.exe"));
  6. In your [Teardown] you add the following:

    _yourApp.Close();

note: I have not verified the NUnit implementation

like image 146
Adam Avatar answered Oct 06 '22 01:10

Adam


As Zian Choy wrote, using the steps provided by Adam, the application under test is not being copied to the .../Out directory. The following additional steps worked for me:

  1. Open your .testsettings file and check the "Enable Deployment" under the "Deployment" section.
  2. Add your binaries under test via "Add Directory...", e.g. "\AppUnderTest\bin\debug"
like image 25
user2075119 Avatar answered Oct 06 '22 00:10

user2075119