gpt4 book ai didi

visual-studio-2010 - 编码的 UI 测试 : Start application under test only if it is not already running

转载 作者:行者123 更新时间:2023-12-01 10:05:36 25 4
gpt4 key购买 nike

在 Visual Studio 2010 中使用“编码的 UI 测试”时,是否有一种简单的方法来启动被测应用程序 (AUT)仅当 AUT 尚未运行时

我知道我可以从头开始实现这样一段启动代码,但我想知道 Visual Studio 测试框架是否提供开箱即用的东西。

最佳答案

似乎可以使用以下代码完成此操作:

[TestInitialize]
public void MyTestInitialize()
{
if (_application != null)
{
return;
}
Process[] processes = Process.GetProcessesByName("ApplicationUnderTest");
if (processes.Length > 0)
{
_application = ApplicationUnderTest.FromProcess(processes[0]);
}
else
{
_application = ApplicationUnderTest.Launch(@"C:\Path\To\ApplicationUnderTest.exe");
}
}

AUT 只有在尚未运行时才会启动。

关于visual-studio-2010 - 编码的 UI 测试 : Start application under test only if it is not already running,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11088283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com