How to access Test suite duration in current Test suite

69 views
Skip to first unread message

Mallikarjunarao Kosuri

unread,
Dec 17, 2018, 8:19:52 AM12/17/18
to robotframework-users
Hello,

Is there way to access test suite execution duration in current Test Suite like https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/Variables.rst#automatic-variables automatic-variables used current Test suite.

If not could you please let me konw how to do that?

Thanks
Malli

Anne kootstra

unread,
Dec 17, 2018, 11:14:47 AM12/17/18
to robotframework-users
Can you explain how you want to use this information? It is possible to use a Robot Framework Listener to track and publish the start and end events from a particular test case/test suite.

Is this what you're looking for? 

Kind regards,

Anne

Op maandag 17 december 2018 14:19:52 UTC+1 schreef Mallikarjunarao Kosuri:

Geist Eng

unread,
Dec 26, 2018, 1:35:42 AM12/26/18
to robotframework-users
As Anne pointed out the elapsed time of the test case can be accessed in a Robot Framework Listener.  The Listener method end_test(...) has this in it attrs var passed to it.

Here is a code snippet from my Listener for integrating to TestRail to record executed test cases:

    def end_test(self, name, attrs):
        # set TR Result data from RF attrs
        result_id = self.result_status_ids[attrs['status']]
        msg = attrs['message'] if attrs['message'] else None
        elapsed_secs = attrs['elapsedtime'] / 1000
        duration = '{}s'.format(elapsed_secs) if elapsed_secs > 0 else '1s'


The end_test 'attrs' argument has a number of data on the just-executed test:

elapsed_secs = attrs['elapsedtime'] / 1000


Reply all
Reply to author
Forward
0 new messages