How to Enable /Disable test step in soapUI using Groovy script (inside each test cases) Based on which teststep user wanted to enable or disable.
Like:
Please find below sample which is throwing error:
Sat May 20 11:35:14 CEST 2017:ERROR:An error occurred [java.lang.NullPointerException], see error log for details while executing the next test cases.
Code:
context.testCase.testSuite.getTestCaseList().each
{
log.info "Test Case : ${it.name}".toUpperCase();
it.testStepList.each
{
log.info "Test Step--> : ${it.name}"
def testStep = testRunner.testCase.getTestStepByName( "${it.name}"
log.info testStep.disabled
if( testStep.disabled )
{
testStep.disabled = false
}
testRunner.testCase.getTestStepByName("${it.name}").setDisabled(true)
log.info testStep.disabled
log.info "Action Perfomed for Test Step : ${it.name}"
}
}
In your code example, def testStep = testRunner.testCase.getTestStepByName( "${it.name}"
is unecessary. It looks for a testStep with a special name in the testSuite containing the script that you run, which isn't there and you get a NullPointer exception. It can be simply replaced by 'it'
context.testCase.testSuite.getTestCaseList().each
{
log.info "Test Case : ${it.name}".toUpperCase();
it.testStepList.each
{
log.info "Test Step--> : ${it.name}"
log.info it.disabled
if( it.disabled )
{
it.disabled = false
}
it.setDisabled(true)
log.info it.disabled
log.info "Action Perfomed for Test Step : ${it.name}"
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.