VS 2010 Coded UI Test - Launch Referenced Application

后端 未结 3 1219
粉色の甜心
粉色の甜心 2020-12-24 07:52

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 dynamica

相关标签:
3条回答
  • 2020-12-24 08:01

    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 --

    1. From inside MS Visual Studio IDE, in Solution Explorer, click on your CodedUI project to highlight it, right click, select "Add", select "Existing item"
    2. In Add Existing Item dialog, navigate to the executable that you want to test within your CodedUI project. Click on the file to highlight it, then locate "Add" drop-down list on the dialog window and select "Add as Link", click OK
    3. Go back to Solution Explorer, click on CodedUI project again and expand it. Now you should see an icon .exe listed inside CodedUI project
    4. Right-click on .exe icon and select "Properties"
    5. In Properties window, set BuildAction to Content and Copy to Output Directory Copy Always

    Voila!!!

    0 讨论(0)
  • 2020-12-24 08:02

    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"
    0 讨论(0)
  • 2020-12-24 08:03

    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

    0 讨论(0)
提交回复
热议问题