Forum Discussion

amysoap's avatar
amysoap
Occasional Contributor
8 years ago

Enable & Disable test steps

Hi,

I am looking for a help. Would you please assist me. I need to disable and enable test steps. 

Below code is not disabling particular steps from Test Steps.

My requirement i want to disable first all the Test steps under test cases then based on scenarios then i need to do enable specific test step. I tried below code as well. But it is not enable/disable specific test steps.

 

http://saurabhguptaqe.blogspot.com/2013/05/enable-and-disable-test-steps-in-soapui.html

 

1) Create a Suite and Test case and test steps then trying to disable all the stpes that i have created. Wants to disable particular test steps.

 

 

def testStep = testRunner.testCase.getTestStepByName( "getDataInputsFromExcel" )

 

if( testStep.disabled ){

              log.info "Disabled"

              testRunner.testCase.getTestStepByName( "getDataInputsFromExcel" ).setDisabled(false)

              }

else

{ log.info "UnDisabled"

              testRunner.testCase.getTestStepByName( "getDataInputsFromExcel" ).setDisabled(true)

}

 

Thanks,

Amy

  • PaulMS's avatar
    PaulMS
    Super Contributor

    Is the groovy script in the same test case as the step named "getDataInputsFromExcel"?

    If not then result is NullPointerException error.

  • gauravkhurana's avatar
    gauravkhurana
    Occasional Contributor

    Amy

     


    // This code dsiable all steps except the current step
    def tc=testRunner.testCase

    // get the current step Name
    String ts=testRunner.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()

    // looping through all steps
    for(def tstp in tc.getTestStepList())
    {
    String testStepName=tstp.getName()

    if(! (testStepName.contains(ts))) // Making sure all steps gets disabled but not this groovy as the code is written here. Otherwise further code will get stopped
    {
    log.info "*** Running test step *** " + testStepName
    tstp.setDisabled(true)
    //tstp.run(testRunner,context)
    }
    }

    // after the above step
    //you can define a variable tstp , get the the teststep reference and disable/enable.run it

     

    //Don't  forget to press the kudos button if it worked for you