list of test step results in groovy script -


i'm trying figure out way list of (names) of failed test steps, below code giving me names

def testcase = testrunner.gettestcase() def steplist = testcase.getteststeplist() steplist.each {     log.info (it.name) } 

now i'm not sure how move on here , failed status of each step in list

you can use follow approach: assertion status of teststeps, , check if status failed, unknown or valid. can use follow groovy code so:

import com.eviware.soapui.model.testsuite.assertable.assertionstatus  def testcase = testrunner.gettestcase() def steplist = testcase.getteststeplist() steplist.each{     // check teststep has assertionstatus      // (for example groovy teststeps hasn't property since     // there no asserts on its)     if(it.metaclass.hasproperty(it,'assertionstatus')){         if(it.assertionstatus == assertionstatus.failed){             log.info "${it.name} fail..."         }else if(it.assertionstatus == assertionstatus.valid){             log.info "${it.name} ok!"         }else if(it.assertionstatus == assertionstatus.unknown){             log.info "${it.name} unknown (probably not executed)"         }     } } 

take in account not teststeps has assertionstatus (like example groovy teststep, why check property in code above).

this code can used in groovy teststep or tear down script testcase.

if need different approach work teststeps instead of teststeps has assertionstatus properties, can use follow code. note first approach advantage if want can use groovy teststep, alternative counterpart follow script can used teardownscript , can works correctly whole test execution since results available @ context:

testrunner.results.each{ teststepresult ->     log.info "${teststepresult.teststep.name} ${teststepresult.status}" } 

teststepresult instance of com.eviware.soapui.model.testsuite.teststepresult can take @ api more info.

hope helps,


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -