Forum Discussion
SmartBear_Suppo
12 years agoSmartBear Alumni (Retired)
Hello again,
I've come up with a solution. I need to tell you that this is really outside the scope of the support offering - we generally don't support Groovy scripts. However, I decided to make an exception for you because my initial suggestion was messed up - sorry about that - and also because your problem piqued my interest so I looked at it in my own time. :-)
Solution that seems to work for me:
1. Add a test case first in your test suite, with a single Groovy test step containing the following code:
def monitor = new com.eviware.soapui.monitor.TestMonitor()
def thisTestCase = context.testCase
thisTestCase.testSuite.testCases.each {
testCase = it.value
if (testCase != thisTestCase && testCase.label != "Wait for completion") {
log.info("Monitoring $testCase.label")
monitor.monitorTestCase(testCase)
}
}
context["#TestSuiteRunner#"].runContext.testMonitor = monitor
2. Create another test case at the end of the suite, with the label "Wait for completion" and the following code:
def monitor = context["#TestSuiteRunner#"].runContext.testMonitor
if (monitor == null) {
log.warn("Monitor not found in completion check")
}
else {
def maxWaitTimeInSeconds = 10
def retries = 0
while (monitor.hasRunningTests() && retries < maxWaitTimeInSeconds) {
log.info("Waiting for tests to complete ...")
try {
Thread.sleep(1000)
}
catch (InterruptedException ignored) { }
retries++
}
log.info("Tests completed: " + !monitor.hasRunningTests())
}
... and then obviously replace the final log statements with the checks you want to perform. By doing this you should be able to fail the whole suite properly.
Hope this helps,
Manne
I've come up with a solution. I need to tell you that this is really outside the scope of the support offering - we generally don't support Groovy scripts. However, I decided to make an exception for you because my initial suggestion was messed up - sorry about that - and also because your problem piqued my interest so I looked at it in my own time. :-)
Solution that seems to work for me:
1. Add a test case first in your test suite, with a single Groovy test step containing the following code:
def monitor = new com.eviware.soapui.monitor.TestMonitor()
def thisTestCase = context.testCase
thisTestCase.testSuite.testCases.each {
testCase = it.value
if (testCase != thisTestCase && testCase.label != "Wait for completion") {
log.info("Monitoring $testCase.label")
monitor.monitorTestCase(testCase)
}
}
context["#TestSuiteRunner#"].runContext.testMonitor = monitor
2. Create another test case at the end of the suite, with the label "Wait for completion" and the following code:
def monitor = context["#TestSuiteRunner#"].runContext.testMonitor
if (monitor == null) {
log.warn("Monitor not found in completion check")
}
else {
def maxWaitTimeInSeconds = 10
def retries = 0
while (monitor.hasRunningTests() && retries < maxWaitTimeInSeconds) {
log.info("Waiting for tests to complete ...")
try {
Thread.sleep(1000)
}
catch (InterruptedException ignored) { }
retries++
}
log.info("Tests completed: " + !monitor.hasRunningTests())
}
... and then obviously replace the final log statements with the checks you want to perform. By doing this you should be able to fail the whole suite properly.
Hope this helps,
Manne
Related Content
Recent Discussions
- 22 days ago