我有这样的代码:
[CodedUITest]
public class CodedUITest1
{
[TestMethod]
public void CodedUITestMethod1( )
{
using(var dlg = new MyWinForm( ))
{
dlg.Show();
System.Threading.Thread.Sleep(2000);
this.UIMap.AssertMethod1( );
this.UIMap.RecordedMethod1( );
this.UIMap.AssertMethod2( );
}
}
}
当我在没有 using 子句直接创建控件的情况下手动启动应用程序(在调用测试之前)时,代码运行良好。
我只想使用引用来创建控件的实例并从那里开始,而不是依赖于尝试确定可执行文件的路径并打开它。该应用程序只是卡在了ContextSwitchDeadlock
.
有没有办法在不启动进程的情况下进行编码 Ui 测试?(使用参考并在测试代码中创建控件)还是我尝试这样做的方式有问题?