1

I am writing a script in AutoIt to test a windows application, and I am using the _Assert function to verify certain actions.

In the documentation I found there is a parameter to say whether or not the script should end if an assertion fails, which is great because in some cases I would like the script to continue, but unfortunately it is still halted by a message box.

Can I override the _Assert function somehow to only print to the console when certain assertions fail, so the script can continue without user interaction?

AdamMc331
  • 16,492
  • 10
  • 71
  • 133

1 Answers1

1

Desired behavior can not be achieved using _Assert(). However, _Assert() can be adjusted to do so (replaced MsgBox() by ConsoleWrite()):

Func _AssertCustom($sCondition, $bExit = True, $nCode = 0x7FFFFFFF, $sLine = @ScriptLineNumber, Const $iCurERR = @error, Const $iCurEXT = @extended)
    Local $bCondition = Execute($sCondition)
    If Not $bCondition Then
        ConsoleWrite("Assertion Failed (Line " & $sLine & "): " & $sCondition & @CRLF)
        If $bExit Then Exit $nCode
    EndIf
    Return SetError($iCurERR, $iCurEXT, $bCondition)
EndFunc

Best to declare as new function (not to change Debug.au3).

user4157124
  • 2,809
  • 13
  • 27
  • 42