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
Kees
Occasional Contributor

The script crashes when I do not comment on "testCase.run (properties, async)" in "Setup Script." When I run the complete script in 'TearDown Script', my script is endlessly repeated.


See attachments.

groovyguy
Champion Level 0

I built this into one of my sample projects so I can better help troubleshoot. I think the problem comes from using this as a tear-down script? Because when the teardown script runs it's own test case, the tear down script is ran again. Which runs the test case, which runs the tear down script again. 

 

There's probably a few ways to handle this and each will need to be built to not enter into an infinite loop as we're seeing. 




---

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

I haven't had a chance to sit down and try my theory yet, but I came up with a way to potentially avoid an infinite loop when using a tear-down script.

 

This will involve setting a property, probably on the test case being ran with the tear down script, and using that flag to control how many times the tear down script runs.

 

 

// IMPORTANT. CAN CAUSE INFINITE LOOP WITHOUT ITERATOR

def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Medewerkers").getTestCaseByName("Niet-gekeurde medewerkers verwijderen")

// check and see if property is true, it should default to true;
if (testCase.getPropertyValue("runTearDown") == "true")
{
	testCase.setPropertyValue("runTearDown", "false");
	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;
		}
	}
}
testCase.setPropertyValue("runTearDown", "true");


 

 

Setting that property to false should prevent the tear-down script from running every time the test case is ran. It should only run the first time. Setting it back to true at the end would let it run the tear down test case again next time you kick off the test case as a whole.




---

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 support!

 

See attachments for my issues.

groovyguy
Champion Level 0

 

I had an oops in the code I posted. I had accidentally defined the test case twice. Here's an update:

 

 
// IMPORTANT. CAN CAUSE INFINITE LOOP WITHOUT ITERATOR

def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName("Medewerkers").getTestCaseByName("Niet-gekeurde medewerkers verwijderen")

// check and see if property is true, it should default to true;
if (testCase.getPropertyValue("runTearDown") == "true")
{
	testCase.setPropertyValue("runTearDown", "false");
	for (i = 0; i < 3; i++)
	{
		def properties = new com.eviware.soapui.support.types.StringToObjectMap ()
		def async = false
		testCase.run (properties, async)
		if (i == 2) 
		{
			break;
		}
	}
}
testCase.setPropertyValue("runTearDown", "true");



---

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

Hello,

 

I tried this script a few times.

 

See attachment for my issues.

groovyguy
Champion Level 0

I tried it myself and am seeing the same problem. Let me go back to the drawing board.




---

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

Hi knees ,
Just by giving break you can stop looping but it is better to know you stopped looping becoz you reached the condition.
Also asynchronous is Boolean value and this will decide test case to run in parallel or sequential mode.

Here is the corrected code snippet:
boolean async=true:// true to run parallel and false to run sequential
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) {
test runner.cancel("i value reached to 2" )
break;}
}

Hip it helps

_Rajendra Prasad Reddy Penumalli

@rajpenumalli: It appears the script you provided still enters into an infinite loop.




---

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

Thank's all. I have now already an solution with a data source loop.

cancel
Showing results for 
Search instead for 
Did you mean: