Forum Discussion

Buschfunk's avatar
Buschfunk
Frequent Contributor
13 years ago

[Solved] How to get test case result via Groovy

Hello,

How can I get the result of a test case using Groovy, i.e. just a simple "PASSED" or "FAILED"? I've found this link (http://www.soapui.org/Scripting-Propert ... ng-results) but it logs all test step results.

Sincerely,
Robert
  • Buschfunk's avatar
    Buschfunk
    Frequent Contributor
    Found the solution:

    def result = testRunner.getStatus()
    if (result == com.eviware.soapui.model.testsuite.TestRunner.Status.valueOf("FINISHED")) {
    log.info("Test passed")
    } else {
    log.info("Test not passed")
    }


    or

    def result = testRunner.getStatus().toString()
    if (result == "FINISHED") {
    log.info("Test passed")
    } else {
    log.info("Test not passed")
    }
    • vikititor's avatar
      vikititor
      Contributor

      I am sorry, but this gives me always "RUNNING" when I try to execute test..

       

      So there is really no way.. how to in side TC get status? 

      Thanks a lot.. I am lost after few hours to found solution.. 

      • vikititor's avatar
        vikititor
        Contributor

        This works only in tear donw script.. but not in groovy test step.. In groovy test step you will get only "RUNNING"..

  • Buschfunk's avatar
    Buschfunk
    Frequent Contributor
    I've found the following code line which gives me the status of the test case.

    def result = testRunner.getStatus()

    However the following does not work:


    def result = testRunner.getStatus()
    if (result == "FINISHED") {
    log.info("Test passed")
    } else {
    log.info("Test not passed")
    }

    Nothing is written to the script log.