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

ExecutionContext.SetCurrentStep via coded test doesn't set current step in test

2 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rory
Top achievements
Rank 1
Rory asked on 22 Jun 2016, 12:42 AM

Greetings,

I'm implementing custom logic to skip test steps and attempting to make use of the ExecutionContext.SetCurrentStep method, which appears to be named in such a way as to suggest this is possible. I can tell the correct step is set by a log statement I've included:

Log.WriteLine("Setting next step to: " + nextStep.CustomOrNormalDescription);

However, calling this method has no effect and appears to silently fail. It makes me wonder what the purpose of this method is. The documentation only offers "Sets the current step to execute against." Can someone explain why this method fails, and if it does not work like expected, how to set the current step for the test in code?

2 Answers, 1 is accepted

Sort by
0
Nikolay Petrov
Telerik team
answered on 24 Jun 2016, 03:14 PM
Hi Rory,

If you want to skip a test step - add coded step with the following code:

- usings:
using ArtOfTest.WebAii.Design.ProjectModel;
using ArtOfTest.Common.Design.ProjectModel;

- body of the method:
// loop over all test's steps
foreach (AutomationStepBase step in ExecutionContext.Current.Test.Steps)
{
    // log the number of the test step - for debugging
    Log.WriteLine(step.Order.ToString());
     
    // will skip 2-nd step in the test
    if (step.Order == 2)
    {
        // disable the step
        step.Enabled = false;
    }
}

You have to add an assembly reference to your project for:

System.Runtime.Serialization -> .NET library
Telerik.TestStudio.Interfaces -> \bin directory of the Test Studio installation

Let me know whether this helps.

Regards,
Nikolay Petrov
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Rory
Top achievements
Rank 1
answered on 24 Jun 2016, 05:19 PM

Thanks Nikolay,

I came up with this same workaround and it does work.

One thing to note for posterity is that in the case of disabling and re-enabling steps, if you have a Logical step that contains verifications that are used in nested Logical steps, it is important to not re-enable the verifications, or they will fail the test if "false". It is important to keep them disabled so the nested Logical step can use it.

Tags
General Discussions
Asked by
Rory
Top achievements
Rank 1
Answers by
Nikolay Petrov
Telerik team
Rory
Top achievements
Rank 1
Share this question
or