Page 1 of 1

How to jump to a particular test-step

Posted: Thu Aug 25, 2016 6:38 am
by ankit26
I have a problem here I want to skip some particular steps if the Test Case Name is say X. Can we do it in ranorex, If yes how?

Re: How to jump to a particular test-step

Posted: Thu Aug 25, 2016 8:03 am
by Martin
Hey

If you want to skip a test case by name then you actually know beforehand what test case you want to skip.

This can be achived by run configurations. You can learn all about these from here: http://www.ranorex.com/support/user-gui ... html#c3019

But if you actually want to skip a module inside a test case related to some previous test modules outcome then you can use some creativity. For example from the top of my head what you could do is set up some variables for both modules and bind them together through databinding. (http://www.ranorex.com/support/user-gui ... sting.html)

You could set the value for the 1st variable to whatever needed (eg. true/false) by what the outcome of the 1st module is. Then catch the value in the next module and with a simple if-statement just either skip everything in that module or continue with it's flow.
public void Flow()
{
    if (varValue == "true")
    {
        UserFunction();
        UserFunction2();
    } else {
        Report.Info("Skip this module");
    }
}

public void UserFunction()
{
    Report.Info("Working on this");
}

public void UserFunction2()
{
    Report.Info("Working on that");
}
Martin

Re: How to jump to a particular test-step

Posted: Thu Aug 25, 2016 1:34 pm
by ankit26
I wanted to skip test-steps in a single module not modules or test case

Re: How to jump to a particular test-step

Posted: Thu Aug 25, 2016 1:38 pm
by Martin
Nevertheless this code example fits perfectly.

The key here is if-statements. Makes it even easier.
public void Flow()
{
    if (varValue == "1")
    {
        UserFunction();
        UserFunction2();
    } else if (varValue == "2") {
        UserFunction();
    } else if (varValue == "3") {
        UserFunction2();
    } else {
        Report.Info("Skip everything");
}

public void UserFunction()
{
    Report.Info("Working on this");
}

public void UserFunction2()
{
    Report.Info("Working on that");
}
If you are just getting into working with user code methods you can always convert your recorded test steps to user code (right click -> Convert to user code) and put them inside a custom method to be called upon.