VS 2010 编码 UI 测试 - 启动引用的应用程序 [英] VS 2010 Coded UI Test - Launch Referenced Application

查看:14
本文介绍了VS 2010 编码 UI 测试 - 启动引用的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次在我的 TFS 服务器上运行构建时,我都会使用 Visual Studio 的编码 UI 测试在 WPF 应用程序上运行自动化 UI 测试.我遇到的问题是根据刚刚构建的路径动态启动可执行文件,包括配置(x86,x64).

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?

推荐答案

MSTest:

  1. 打开您的 .testsettings 文件并选中部署部分下的启用部署".
  2. 在您的测试项目中右键单击并选择添加现有项.
  3. 浏览到要测试的应用的构建位置.
  4. 找到您的可执行文件并选择添加为链接"(如果您的测试项目尚未引用它们,请确保您包含所有依赖于应用的 DLL.)
  5. 右键单击可执行文件的链接并选择始终复制"(这将在构建时将新版本的 .exe 复制到您的测试 bin 目录中)
  6. 在您的 [TestInitialize] 中添加以下内容以启动您的应用:

  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"));

  • 在您的 [TestCleanup] 中添加以下内容:

    _yourApp.Close();

  • NUnit:(您需要参考和使用 Microsoft.VisualStudio.TestTools.UITesting)

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

    1. 在您的测试项目中右键单击并选择添加现有项.
    2. 浏览到要测试的应用的构建位置.
    3. 找到您的可执行文件并选择添加为链接"(确保您包含所有依赖于您的应用如果您的测试项目尚未引用 DLL.)
    4. 右键单击可执行文件的链接并选择始终复制"(这将在构建时将新版本的 .exe 复制到您的测试 bin 目录中)
    5. 在您的 [Setup] 中添加以下内容以启动您的应用:

    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"));

  • 在您的 [Teardown] 中添加以下内容:

    _yourApp.Close();

  • 注意:我还没有验证 NUnit 的实现

    note: I have not verified the NUnit implementation

    这篇关于VS 2010 编码 UI 测试 - 启动引用的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆