Reputation: 221
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?
Upvotes: 22
Views: 12609
Reputation: 11
I've been struggling for some time with trying to figure out how to tell my CodedUI project where to launch the executable from and how to do it "right", so it works automatically when different users run the code in different workspaces, on different hosts etc. I did come up with copying the executable into a shared directory (step in the right direction) and then recording an action to start it from there (band aid, so it at least works for different users on the same host).
Here are the steps from your MSTest instructions, adapted for MS Visual Studio 2015 Enterprise IDE. Sadly, I do not have enough "reputation points" to be able to embed screen shots --
Voila!!!
Upvotes: 1
Reputation: 41
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:
Upvotes: 4
Reputation: 3013
MSTest:
In your [TestInitialize]
add the following to launch your app:
_yourApp = ApplicationUnderTest.Launch(Path.Combine(Directory.GetCurrentDirectory(), "yourexecutablename.exe"));
In your [TestCleanup]
you add the following:
_yourApp.Close();
NUnit: (you will need to reference and use Microsoft.VisualStudio.TestTools.UITesting)
In your [Setup]
add the following to launch your app:
_yourApp = ApplicationUnderTest.Launch("yourexecutablename.exe"));
In your [Teardown]
you add the following:
_yourApp.Close();
note: I have not verified the NUnit implementation
Upvotes: 24