This is a migrated thread and some comments may be shown as answers.

Set test to PASS when certain step passed

1 Answer 142 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Helen
Top achievements
Rank 1
Helen asked on 11 Oct 2011, 06:56 PM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Cody
Telerik team
answered on 11 Oct 2011, 09:36 PM
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
Tags
General Discussions
Asked by
Helen
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or