I am writing automated tests using AutoIt:
Func MyTest($sInput)
Local $oTest = NewTest("Test Name")
$oTest.Setup()
;Run steps
$oTest.Assert($sSomeExpected, $sSomeActual)
$oTest.Teardown()
EndFunc
Inside Assert()
I set test's result to failed if the assertion fails. I would like to end the test completely but not the entire script, because my script looks like this:
For $i = 0 To UBound($aInputs) - 1 Step 1
MyTest($aInputs[$i])
Next
If the test fails for input 1 I still want to run the test for the other inputs. Ideally I want to handle this in Assert()
:
Func _assert($oSelf, $sExpected, $sActual)
If Not($sExpected = $sActual) Then
$oSelf.Result = 0
;Return from MyTest function without ending script??
EndIf
EndFunc
Is it possible to return from MyTest()
from inside Assert()
? I can exit the script but that requires one script for every test which gets bloated quick. The workaround I have is awful (return True/False from Assert()
and check it in MyTest()
):
If Not($oTest.Assert($sSomeExpected, $sSomeActual)) Then Return
It makes code unreadable and difficult to maintain. Is there a way to have MyTest()
return if Assert()
fails without handling it each time I call Assert()
?