I create automated tests with Test Automation FX and I'm beginner.

I need to know how to fail test from within test script?

I am using C# scripting.

Say if I want to recognize some window control and have to perform action on that:

if(window["Exists"])
{
    //Perform action.
}
else
{
    // move to the next test cases.
}

I don't know how to handle the else part?

有帮助吗?

解决方案

To report failure of test case when window does not exist you can use following methods of of Verify class from Test Automation FX API:

with FailTest method:

    if (window["Exist"])
    {
        // Perform actions
    }
    else
    {
        Verify.FailTest("Window does not exist"); // Report failure message that will be shown in test report
    }

with AreEqual method:

    Verify.AreEqual(window["Exist"], true); // will fail test if window dows not exist
    // Perform actions
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top