Visual studio 2010 大于签入编码的UI测试
在使用Assert函数进行CodedUI测试时,如何检查诸如大于、小于之类的操作Visual studio 2010 大于签入编码的UI测试,visual-studio-2010,coded-ui-tests,assert,Visual Studio 2010,Coded Ui Tests,Assert,在使用Assert函数进行CodedUI测试时,如何检查诸如大于、小于之类的操作 我正在使用Visual Studio 2010 Ultimate。您可以通过自定义代码添加任何其他自定义断言。遵循以下步骤 首先在属性上添加任何断言,并为验证方法生成代码 将验证方法从UIMap.Designer.cs移到UIMap.cs 现在在验证方法中自定义UIMap.cs中的代码。以下是一个例子: /// <summary> /// Verifies that the result count i
我正在使用Visual Studio 2010 Ultimate。您可以通过自定义代码添加任何其他自定义断言。遵循以下步骤 首先在属性上添加任何断言,并为验证方法生成代码 将验证方法从UIMap.Designer.cs移到UIMap.cs 现在在验证方法中自定义UIMap.cs中的代码。以下是一个例子:
/// <summary>
/// Verifies that the result count is > the min value passed.
/// </summary>
public void VerifyMinimumResultCount(int minResultCount)
{
HtmlSpan totalResults =
this.ApplicationWindow.
IntermediateParent.TotalResultsTextBox;
// Use regular expression to get the text out of the
// Control Property.
int actualResultCount;
Match resultPattern = Regex.Match(totalResults.Text,
"[0-9]+-[0-9]+ of ([0-9,]*) results");
Assert.IsTrue(resultPattern.Success,
"Regular expression match failed");
Assert.IsTrue(int.TryParse(resultPattern.Groups[1].Value,
NumberStyles.Number,
CultureInfo.CurrentCulture,
out actualResultCount),
"Parsing failed");
Assert.IsTrue(actualResultCount >= minResultCount,
"Got less than expected min result");
}
来源:我的回答有用吗?你需要更多的信息吗?
//...
int expectedValueLimit = 2;
int actualValue = int.Parse(myUiControl.text);
Assert.IsTrue((actualValue > expectedValueLimit), "myUiControl value is less than " + expectedValueLimit);
//...