I am automating some test cases with Coded-UI And I am trying to figure out how to explicitly fail a test case from the code instead of waiting for the code to timeout. I considered creating an assertion that is bound for failure, but that feels sloppy to me. Here is an example of my code:
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
I looked around for a while but could not find anything specific to Coded-UI that allows me to fail the test case.
Thank you!