Forum Discussion

Fjaloma's avatar
Fjaloma
New Contributor
6 years ago

New User- Can I automate just Test Steps?

Using Soap UI 5.4.0 - I have a project, I have a test case, I have multiple test steps (66). I want to execute only the first 22 test steps and leave the remainder unexecuted. How do I do this?

There is not server set up, table reset etc. required. These steps just execute and generate a known response. and move on to the next test step. 

 

Thoughts?

 

Frank

4 Replies

  • Hi Fjaloma,

     

    Add a groovy step at 1st place and use below code and execute only that groovy step:

     

    def tsToExecute = 22
    for(def i=1;i<=tsToExecute;i++)
    {	
    	ts = testRunner.testCase.getTestStepAt(i)
    	ts.run(testRunner, context)
    }

    Click "Accept as Solution" if my answer has helped, and remember to give "kudos" :)

     

    Thanks and Regards,

    Himanshu Tayal

  • richie's avatar
    richie
    Community Hero
    Hi Frank,

    I don't know if i'm misunderstanding the significance of your issue, but if you have numerous steps in your test case, can you not jist disable the steps? This would result on execution that only the enabled test steps would be exercised.

    I have soapui 3.5 and readyapi1 2.4.0 installed and in soapui 3.5 you can't disable multiple steps in one go (e.g. highlight >1 step and select disable) you can only disable a single step at a time, but in readyapi you can highlight multiple steps (shift and cursor key) then right click and disable multiple steps in one go.

    As i say, i mighy be misunderstanding your problem, but from my understanding of your issue, this is what i would do.

    Cheers,

    richie
  • Radford's avatar
    Radford
    Super Contributor

    I would be looking at how you are structuring your tests.

     

    You say that all of your steps are in a single test case, but you only want to run the first 22. While I don't know the details of your tests but if you regularly wanting to run just the first 22 I would consider splitting them into a separate appropriately named test case, so when you just need the first 22, just run the test case. You can then always run all of them by running the parent test suite.

     

    If on the other hand it is just a once only (or very rare) requirement to run just the first 22 then the disable steps method mentioned by richie is ideal.

  • jhanzeb1's avatar
    jhanzeb1
    Frequent Contributor

    Hi,

     

    you can disable them from the UI and then run the test or you can use groovy to disable them with a condition.

     

    An example would be below:

    //if you are data driving the tests, it would have a unique id or number which is stored in custom prop

    def test_case_id = context.expand( '${#TestCase#test_case_id}' )

     

    //if your testcase has xyz condition then enable xxx testSteps and disable xxz testSteps

    if (test_case_id == '001') {

    testRunner.testCase.getTestStepByName( "exact name of disabled testStep" ).disabled = false

    testRunner.testCase.getTestStepByName( "exact name of  enable teststeps" ).disabled = true

    }

    else if (test_case_id == '002'){

    testRunner.testCase.getTestStepByName( "testStepname" ).disabled = true

    testRunner.testCase.getTestStepByName( "testStepname" ).disabled = false

     

    That should help you I hope :)