如何使用Coded-UI显式地使测试用例失败

时间:2012-06-12 17:38:26

标签: c# testing coded-ui-tests

我使用Coded-UI自动化一些测试用例我试图找出如何从代码中显式地使测试用例失败,而不是等待代码超时。我考虑创建一个必然会失败的断言,但这对我来说感觉很草率。以下是我的代码示例:

public bool CheckifFileExists(String SearchFile, int secondswait)
    {
        bool FileExists = File.Exists(SearchFile);
        int i = 0;
        while (FileExists == false && i <= secondswait)
        {
            FileExists = File.Exists(SearchFile);
            System.Threading.Thread.Sleep(1000);
            i++;
        }

        return (FileExists);
    }


bool FileExistsStatus = CheckifFileExists(SearchFile, secondswait);

if(FileExistsStaus == true)
    //continue test case
else
    //explicitly fail test case

我环顾了一会儿,但找不到任何特定于Coded-UI的内容,这让我无法通过测试用例。

谢谢!

1 个答案:

答案 0 :(得分:4)

从我对问题的评论转移到答案。

Assert.IsTrue(FileExistsStatus)怎么样?

相关问题