tdrury
13 years agoContributor
calling fail() on LoadTestRunner hangs soapui
Using soapUI Pro 4.5.1 on Windows 7.
I have the following groovy script test step within a test case. The intent is to stop the load test if any thread in the load test gets an error from our server during this particular soap request:
This script detects if the test case is being run within a load test and, if so, calls fail() on the LoadTestRunner. This causes an error dialog to pop-up in soapUI telling me the test failed (this is fine), but after clicking 'OK', soapUI is hung. I have no choice but to kill it via the Task Manager.
Initially I tried calling "testRunner.fail('request failed')" but this seems to only fail the test case - the load test keeps running (less the thread that just failed).
Am I doing something wrong? How do I stop the entire load test if one of the threads detects a failure?
-tim
I have the following groovy script test step within a test case. The intent is to stop the load test if any thread in the load test gets an error from our server during this particular soap request:
def responseHeaderCode = testRunner.testCase.testSteps['Start'].testRequest.response.responseHeaders['#status#']
def code = responseHeaderCode.get(0).split(' ')[1]
if (code != '200') {
def responseString = testRunner.testCase.testSteps['Start'].testRequest.response.contentAsString
log.error 'Thread['+context.ThreadIndex+'] Run['+context.RunCount+']: Start failed:'
log.error '->'+responseString
if (context.LoadTestContext != null) {
context.LoadTestContext.loadTestRunner.fail('load test failed at Start - see logs')
}
}
This script detects if the test case is being run within a load test and, if so, calls fail() on the LoadTestRunner. This causes an error dialog to pop-up in soapUI telling me the test failed (this is fine), but after clicking 'OK', soapUI is hung. I have no choice but to kill it via the Task Manager.
Initially I tried calling "testRunner.fail('request failed')" but this seems to only fail the test case - the load test keeps running (less the thread that just failed).
Am I doing something wrong? How do I stop the entire load test if one of the threads detects a failure?
-tim