Forum Discussion

MOTOROLA_Suppor_1's avatar
15 years ago

how to access/reference user opened log file ??

Is it possible that I could get some kind example of pass file handler to event handler:

1 Suppose I have testSuite(or global level ) property: LOGFILE_HANDLER

2. From every testcase, I have 'setup script' to open a new log file. something like:

def outFile = new File("D:/XML-Testing/WebNBI/SoapUIPro/TestResultR7.3/TestCase1.log");

3. On the same 'setup script' I want to pass this file handler to property. something like:
SoapUI.getGlobalProperties().getProperty('LOGFILE_HANDLER').setValue(...)

4. In event handler to get this file handler and log the request/response content
def log_file = SoapUI.getGlobalProperties().getProperty('LOGFILE_HANDLER') ?
def req_str = context.getProperty("requestContent");
log_file.write (req_str);

I need some help on save and reference file handler (step 3 and step 4 ) .. thanks a lot

sheena

1 Reply

  • I find the solution by search the Forum topic:

    in 'setup script' once open the outFile, do this:

    context.setProperty("myLogFile", outFile)

    in event handler:
    ....
    if ( context.myLogFile) {
    def f = context.myLogFile;
    f.append( req_str)
    }