Forum Discussion

SiKing's avatar
SiKing
Community Expert
12 years ago

getTimeTaken units?

For TestRunner.getTimeTaken() the description says: "Returns the time taken by this runner since its last start" What are the units??? I assumed it would be milliseconds, but that does not seem to be the case.

I have a simple testcase that runs a Groovy step in a loop:

log.info "testRunner.timeTaken = ${testRunner.timeTaken}"

if(testRunner.timeTaken > 20 * 60 * 1000) {
testRunner.fail("${context.testCase.name} too long to find valid current issue!")
return
}


Here is a snippet of the log:

2014-03-12 07:30:48,957 INFO [log] testRunner.timeTaken = 43102
.....
2014-03-12 08:43:48,438 INFO [log] testRunner.timeTaken = 608137

Those numbers do not seem to add up to anything.

3 Replies

  • Hi,

    The function returns the time elapsed in milliseconds testrunner has been running.

    I ran the following code in a Groovy test step:


    log.info "testRunner.timeTaken = ${testRunner.timeTaken}";

    while (true)
    {

    if(testRunner.timeTaken > 20 * 60 * 1000) {
    testRunner.fail("${context.testCase.name} too long to find valid current issue!");
    break;
    }

    }

    log.info "testRunner.timeTaken = ${testRunner.timeTaken}";
    log.info "done";


    This was logged:

    Wed Mar 12 14:06:45 EDT 2014:INFO:testRunner.timeTaken = 170
    Wed Mar 12 14:26:45 EDT 2014:ERROR:Failed with reason [base64_encode_decode too long to find valid current issue!]
    Wed Mar 12 14:26:45 EDT 2014:INFO:testRunner.timeTaken = 1200017
    Wed Mar 12 14:26:45 EDT 2014:INFO:done

    1200017 in milliseconds is 20 minutes which is how long testrunner is suppose to run before failing.


    Regards,
    Marcus
    SmartBear Support
  • SiKing's avatar
    SiKing
    Community Expert
    I think I might have found my problem: My testcase has Abort on Error = false. This causes the testrunner to not stop even when it hits the testRunner.fail() and return.
    Which API call can I use to just stop the test?