Set test to PASS when certain step passed

2 posts, 1 answers
  1. Helen
    Helen avatar
    2 posts
    Member since:
    Oct 2010

    Posted 11 Oct 2011 Link to this post

    Hi
    I was wondering - is there a possibility to set the whole test to pass if a certain step passed?

    The situation I'm in is:
    I recorded a test with certain steps. Some of them(say, steps in the middle of the test)  sometimes pass, sometimes fail. This is expected behavior and to let the test proceed I set these steps to "continue on failure". But, in case some of the steps failed, regardless of the fact that test actually ran successfully, the whole test is set to fail.
    Currently I created a workaround, when the last step in test writes to test-list log.
    But I want to integrate my tests into "build" process for our software.
    It would be great if there was a way to set the test to PASS if the last step of the test ran with success.

    Thanks in advance
    Helen
  2. Answer
    Cody
    Admin
    Cody avatar
    3354 posts

    Posted 11 Oct 2011 Link to this post

    Hi Helen,

    Well, you could try adding this code to the code behind file for your test:

    public override void OnAfterTestCompleted(TestResult result)
            {
                result.Result = result.StepResults[result.StepResults.Count - 1].ResultType;
                base.OnAfterTestCompleted(result);
            }


    This code will force the overall pass/fail result for the whole test to be set based on the results of the very last test step.

    If it were me however I'd look for a way to make all the middle steps show Pass no matter what. For example convert them to code then wrap them in a Try Catch block. This way even if an assertion fails, the test step will be marked Passed.

    Best wishes,
    Cody
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top