Forum Discussion

radhikac57's avatar
radhikac57
Occasional Visitor
11 years ago

getting null pointer exception on file.write while trying to capture results

When the below script is used for capturing test results in soapui , NullPointerException is thrown at line 12 : File.write()

import com.eviware.soapui.impl.wsdl.testSteps.*
defGroovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def path= testRunner.testCase.testSuite.getPropertyValue("Results_Path")
new File(path).mkdir()
for(testCase in context.testCase.testSuite.getTestCaseList())
{
for(teststep in testCase.getTestStepList())
{

def ts_name = teststep.getName()
def req = teststep.getPropertyValue("Request")
new File(path + "/" + ts_name + "_" + "Request" + ".xml").write(req , "UTF-8")
def res = teststep.getPropertyValue("Response")
new File(path + "/" + ts_name + "_" + "Response" + ".xml").write(res)

}
}

 

Please help me on how to avoid this NullPointerException

1 Reply

  • nmrao's avatar
    nmrao
    Community Hero

    Can you attach the stacktrace from error log?