断言函数比较c#中2种不同方法返回的字符串

时间:2016-12-09 16:02:32

标签: c# selenium-webdriver automated-tests nunit assertions

我在c#selenium框架中有2个方法。我正在使用Nunit框架进行测试

public String method1()

{

String s  = "This is example 1";

return s

}

public string method2()

{

String s = "example 2";

return s;

}

我需要检查两个字符串是否包含相同的特定文本'示例'。是否有一个“断言”'功能比较?

1 个答案:

答案 0 :(得分:1)

根据您的回复,听起来您只需要使用:

string one = method1();
string two = method2();
StringAssert.Contains(two, one);
相关问题