VS 2010 Coded UI Test - Launch Referenced Application

后端 未结 3 1268
粉色の甜心
粉色の甜心 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: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

提交回复
热议问题