Coded UI-Continue the test run in spite of error

怎甘沉沦 提交于 2019-12-25 00:34:45

问题


My test case contains more than 10 assertions.Assume there is a problem in the third assertion(ie.) the Ui or object I have used for the third assertion is not recognized by the tool.Now the entire test case fails saying "Unable to find the control",the rest part of the same test case is not done.

Is it feasible to run the test case fully( to continue with all the other assertions, in spite of error in the third assertion,assuming the unrecognized control is used only for the third assertion.)

regards Amsa


回答1:


The only way is messy. Coded UI works with assertions which are intended to be interpreted as "[something] should be true here and, if not, stop immediately failing the test".

There are various approaches to avoiding the "stop immediately" part, but most boil down to code of the style:

try {
    ... an assertion ...
}
catch (...)
{
    ... remember and/or report the detail of the failed assertion ...
}

try {
    ... another assertion ...
}
catch (...)
{
    ... remember and/or report the detail of this failed assertion ...
}

if ( any assertion above was caught OR anything was remembered )
{
    // Something failed.
    report the remembered items
    Assert.Fail(... some message...);
}

The try...catch...{} can be repeated as necessary. The catch clauses can be difficult to write unless you only catch the most general exceptions. The code that does the reporting and remembering may throw exceptions. Between the try... statements there may be calls of non-assertion methods that may fail, so these would also need to be wrapped in try... statements. The whole test gets very cumbersome and risks having faults that are detected and remembered but not reported because of a later unhandled exception.



来源:https://stackoverflow.com/questions/23755899/coded-ui-continue-the-test-run-in-spite-of-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!