Ask a Question

How can I autoreplay one of my testcases?

SOLVED
Kees
Occasional Contributor

How can I autoreplay one of my testcases?

Hello,

 

I would like to autoreplay one of my testcases. Is that possible within SoapUI NG pro? And so yes, on what manner?

 

Kind regards,

 

Kees

19 REPLIES 19
nmrao
Champion Level 3

If the test case is created earlier, then the same can be run any number of times.


Regards,
Rao.
IgorG
Staff

You can use test case Teardown scripts to do this. This script should work, but there are probably lots of simpler ways.

 

 

// IMPORTANT. CAN CAUSE INFINITE LOOP WITHOUT ITERATOR
for (i = 0; i <1; i++) { def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("TestSuite 1").getTestCaseByName("TestCase 1") def properties = new com.eviware.soapui.support.types.StringToObjectMap () def async = false testCase.run (properties, async) }

 

API Bloom
Kees
Occasional Contributor

Igor, thank you very much!


That script works! But another question. How can I stop that script during the loop? Or is there an option that I can replay the script for 10 or another number times?

You can use this notation to exit the loop at any time:

if(condition) {
    break;
}

Or you can change the i=x value in the loop to run a specific number of times.

API Bloom
Kees
Occasional Contributor

See for my question the attachment.
groovyguy
Champion Level 0

If you want the loop to run the test suite 3 times, you would use

 

 

for (int i = 0; i < 3; i++)
{
     ...........
}

 

If you want the loop to run a MAX of 3 times and stop if a certain condition is met:

for (int i = 0; i < 3; i++)
{
     ...........
     if (condition == true)
     {
          break;
     }
}

 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Kees
Occasional Contributor

Thank you for your response.

 

It does not work. What can I do? Is my script (see below) wrong?

 

My complete TearDown Script is now:

 

// IMPORTANT. CAN CAUSE INFINITE LOOP WITHOUT ITERATOR
for (i = 0; i < 3; i++)
{
def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Medewerkers").getTestCaseByName("Niet-gekeurde medewerkers verwijderen")
def properties = new com.eviware.soapui.support.types.StringToObjectMap ()
def async = false
testCase.run (properties, async)
if (i == 2) {break;}
}

Kees
Occasional Contributor

I think that this code is wrong: "testCase.run (properties, async)". But I don't know what I must write there.

groovyguy
Champion Level 0

When you say it does not work, what error are you getting or what is not working?




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
cancel
Showing results for 
Search instead for 
Did you mean: