Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

Coded UI-Continue the test run in spite of error

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...