PureUnit triggers GUI alert on fail
Posted: Wed Oct 01, 2025 12:45 pm
Calling Assert() with a falsy expression or Fail() inside a module triggers a GUI alert (MessageRequester) when calling PureUnit.exe from the command line.
Test case
test.pbi
This will show MessageRequester where the error occured instead of printing the error to console.
Why have Assert() or Fail() inside a module? Typically a TestHelper module to make testing easier. Calling Assert() or Fail() inside a standalone procedure works as expected.
Personally I would prefer if PureUnit.exe was cli only and PureUnitGui.exe was the GUI PureUnit, to avoid any pontential problems when running PureUnit.exe in batch jobs.
Calling PureUnit.exe without any arguments launches the PureUnit GUI, perhaps showing help would be better.
Test case
test.pbi
Code: Select all
Procedure MyProcedure()
Assert(#False)
EndProcedure
DeclareModule MyModule
Declare MyProcedure()
EndDeclareModule
Module MyModule
Procedure MyProcedure()
Assert(#False)
EndProcedure
EndModule
ProcedureUnit TestMyProcedure()
MyProcedure()
EndProcedureUnit
ProcedureUnit TestMyModuleMyProcedure()
MyModule::MyProcedure() ; Triggers GUI alert
EndProcedureUnit
Code: Select all
"%ProgramFiles%\PureBasic\SDK\PureUnit\PureUnit.exe" /ignore test.pb
Why have Assert() or Fail() inside a module? Typically a TestHelper module to make testing easier. Calling Assert() or Fail() inside a standalone procedure works as expected.
Personally I would prefer if PureUnit.exe was cli only and PureUnitGui.exe was the GUI PureUnit, to avoid any pontential problems when running PureUnit.exe in batch jobs.
Calling PureUnit.exe without any arguments launches the PureUnit GUI, perhaps showing help would be better.