【发布时间】:2015-01-19 17:23:24
【问题描述】:
您好,我知道我要问的问题已经被其他人问过了,但是我仍然不清楚那些已经在网上发布的内容,因此我发布这个问题是为了澄清我的疑问。希望大家能帮帮我。
目前我正在使用 Microsoft Visual Studio 2013 Premium。我正在使用记录和播放功能。我记录了一些动作和一些验证点。现在,当验证点失败时,脚本将立即停止。但是,即使某些点失败,我也希望脚本继续运行。我在网上阅读了一些选项,但是我不知道应该将它们放在我的脚本中的哪个位置。 我看到了这篇文章Coded UI - "Continue on failure" for Assertions 但是我没有使用 SpecFlow 是否仍然适用于我?我应该把这些代码放在哪个部分?在我的方法里面?创建一个新方法?还是?
bool thisTestFailed = false;
if ( ... the first assertion ... ) { thisTestFailed = true; }
if ( ... another assertion ... ) { thisTestFailed = true; }
if ( ... and another assertion ... ) { thisTestFailed = true; }
if ( thisTestFailed ) {
Assert.Fail("A suitable test failed message");
}"
【问题讨论】:
-
一个断言,并不意味着使用 Assert.SomeCondition()。只需使用简单的条件来设置 thisTestFailed。
标签: c# coded-ui-tests assertions