testing - How can I return from a calling function to end a test without ending the script? -
i writing automated tests using autoit , follow basic format:
func mytest($sinput) local $otest = newtest("test name") $otest.setup() ;run steps $otest.assert($ssomeexpected, $ssomeactual) $otest.teardown() endfunc
inside assert function, set test's result failed if assertion fails. end test completely, not end entire script. because script may this:
for $i = 0 ubound($ainputs) - 1 step 1 mytest($ainputs[$i]) next
so if test fails input 1, still want able run test other inputs. ideally, handle in assert:
func _assert($oself, $sexpected, $sactual) if not($sexpected = $sactual) $oself.result = 0 ;return mytest function without ending script?? endif endfunc
i don't know if it's possible return mytest inside assert. can exit script, explained don't want that. if went approach, means creating 1 script every test bloated extremely quick.
the workaround have right now, awful, return true/false assert , check each time in mytest
:
if not($otest.assert($ssomeexpected, $ssomeactual)) return
but think makes code unreadable , difficult maintain.
is there way have mytest return if assert fails without handling each time call assert?
Comments
Post a Comment