Forum Discussion

EADS_Support's avatar
EADS_Support
Occasional Contributor
15 years ago

Datasink property not getting set correctly with Grvy Script

Hi

I have two groovy script steps within my test case to output a start and end time to properties within a data sink set within a data source loop (note the set time scripts both sit outside of the loop)

when the test runner goes through the output log returns the values as you would expect,
i.e.
09:01:51,601 INFO [log] StartT: =09:01:51
09:04:42,836 INFO [log] EndT: =09:04:42

however when looking into the datasink output only the start time is evident and no end time value exists


StartTime script:-
Starttime = new Date();
timeformat = new java.text.SimpleDateFormat('hh:mm:ss');
Starttimefmtd = timeformat.format(Starttime);
def dataSink = testRunner.testCase.testSteps['DataSink'];
dataSink.setPropertyValue('StartTime', Starttimefmtd);
dataSink.setPropertyValue('EndTime', "");
log.info ("StartT: ="+Starttimefmtd);


End Time script:-
Endtime = new Date();
timeformat = new java.text.SimpleDateFormat('hh:mm:ss');
Endtimefmtd = timeformat.format(Endtime);
def dataSink = testRunner.testCase.testSteps['DataSink'];
dataSink.setPropertyValue('EndTime', Endtimefmtd);
log.info ("EndT: ="+Endtimefmtd);
  • Hi,

    are you running this script in the TestCase TearDown? In that case it is "too late" to add data to a DataSink.. try adding a groovy script step at the end of the TestCase that does this instead..

    does that help?

    regards!

    /Ole
    eviware.com
  • EADS_Support's avatar
    EADS_Support
    Occasional Contributor
    Hi Ole

    I did initially put the code into the start up/tear down scripts but realised that this wasn't working as I'd expected so I then created groovy script test steps within the test case to do this with a similar result


    the test case currently looks like this

    test case
    test steps
    StartTime script
    Data source
    Soap req
    Groovy script
    Prop Transfer
    Datasink
    Data Loop
    EndTime script


    Cheers
    Mike
  • Hi Mike,

    The problem is that nothing is saved to the DataSink until the DataSink step itself it executed. When the last script sets the datasink attributes, the datasink is never again executed, since the loop has ended. You can manually run the DataSink TestStep again, outside the loop, to save these values. Try adding the following line to your groovy End Time script (after setting th dataSink properties):


    testRunner.runTestStepByName('DataSink')


    Regards,
    Dain
    eviware.com