The error message is clear, context.fileReader
is null because there is no property fileReader
inside context
, this is why you get the NPE
when you invoke readLine()
on it.
To use context.fileReader
, first you've to set something in the property, for example in your case:
context.fileReader = new FileReader("/myTempFile.txt")
def nextLine = context.fileReader.readLine()
if(nextLine != null){
String[] propData = nextLine.split(",")
curTC = testRunner.testCase
This example has non sense at all, it's only illustrative; normally context
in SOAPUI is used to pass different objects from one testStep to another inside a TestCase execution, or from one TestCase to another inside a TestSuite etc...
For example you have a TestCase and want to pass a property through different testSteps, in one TestStep you set the property as:
context.fileReader = new FileReader("/myTempFile.txt")
And then in another TestStep you get it back to use it as:
def nextLine = context.fileReader.readLine()
Hope this helps,