Forum Discussion

manishddeshmukh's avatar
manishddeshmukh
New Contributor
11 years ago

Run particular groovyscript teststeps and ignore other

hi,

My requirement is...if i have 5 groovy script (Gs) teststeps and want to run only Gs1, Gs2 & Gs5 and ignore Gs3 & Gs4 using external Batch File (say testRunner), how can i do that?

I tried the following, but not achieved what i want...

testRunner.gotoStepByName( "nameofteststep" )
&
testRunner.runTestStepByName( "nameofteststep" )

Specific Solutions & Suggestions are welcome. Thanks in advance...
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    Personally I would have each groovy script check a property value as to whether they should do their functions or not. With testRunner you can pass in the propert(y|ies) and then have the groovy scripts check if the flag for it was set to run or not.


    For example using a CSV style property that will check:

    if (!testRunner.testCase.testSuite.project.getPropertyValue("scripts").toString().contains(context.testCase.getTestStepAt(context.getCurrentStepIndex()).getName())) {
    log.info "This step is disabled";
    return;
    }

    //The code for the Groovy script would go here
    log.info "Nope, not disabled";



    Basic explanation:

    It checks the property value scripts for the name of the current script. If it is not there it just returns. If it is there, it skips the return and continues on with the script. Very simple, the groovy scripts still run (I suppose you could do a controller script that will disable them but this will be easier IMO).

    If you put the above into it, as long as the groovy scripts do not have extremely similar names (For example, dog and dog2 would always trigger dog when dog2 is triggered with this current script).

    Enjoy.
  • Thanks Paul...

    I will try this code and will get back to you. Hope this should work out for my requirement.