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

3 posts, 0 answers
  1. Rory
    Rory avatar
    16 posts
    Member since:
    Jun 2011

    Posted 21 Jun 2016 Link to this post


    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. Nikolay Petrov
    Nikolay Petrov avatar
    308 posts

    Posted 24 Jun 2016 Link to this post

    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
        // 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.

    Nikolay Petrov
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. Rory
    Rory avatar
    16 posts
    Member since:
    Jun 2011

    Posted 24 Jun 2016 in reply to Nikolay Petrov Link to this post

    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.

Back to Top