Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
16 years ago

failed test step status

Hello,
I am trying to check if a certain test step failed but am having some problems. my code is

for( r in testRunner.results )
{
if (r.status == "FAILED")
          log.info("some test step failed")
}

it doesn't seem like its working. What am I doing wrong?

Thanks

ALi
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    hmm.. try

    for( r in testRunner.results )
    {
      if (r.status.toString() == "FAILED")
              log.info("some test step failed")
    }

    instead?


    /Ole
    eviware.com
  • alibaba82's avatar
    alibaba82
    Super Contributor
    how would i write something like

    if (certainteststep.status = failed)
    log.info('teststep1 failed')

    Ali
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    you would have to find the corresponding teststepresult in the list of results.. something like..

    for( r in testRunner.results )
    {
        if( r.testStep == testRunner.testCase.testSteps["teststep1"] &&
            r.status.toString() == "FAILED" )
          log.info( "teststep1 failed" 
    }

    regards!

    /Ole
    eviware.com
    • Z19942's avatar
      Z19942
      Occasional Contributor

      Hi,

      Where do we put this loop? 

      in Tear Down script for test Runner? or within the steps by adding a groovy script step?

  • alibaba82's avatar
    alibaba82
    Super Contributor
    is it possible to print the status of the 'teststep1' without using the for loop described below.

    I just want to something like

    def blah =  testRunner.testCase.testSteps["teststep1"]
    log.info(blah.status.toString())

    If this is not possible, can a script assertion accomplish on the teststep accomplish this ?
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    sorry, there is no such method, the teststep does not save its last executed status. You wouldn't be able to do it in a script-assertion since that is executed to calculate the status itself. We could add a method to the testrunner though, something like getLastStatus( stepName )?

    /Ole
    eviware.com