Page 1 of 1

PureUnit triggers GUI alert on fail

Posted: Wed Oct 01, 2025 12:45 pm
by tored
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

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
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.

Re: PureUnit triggers GUI alert on fail

Posted: Wed Oct 01, 2025 3:34 pm
by Fred
As we have 2 version, it makes sense than the console version would be without GUI. That said, you can use the '-q' flag (quiet) which should solve your requester issue.

Re: PureUnit triggers GUI alert on fail

Posted: Wed Oct 01, 2025 4:43 pm
by tored
Fred wrote: Wed Oct 01, 2025 3:34 pm As we have 2 version, it makes sense than the console version would be without GUI. That said, you can use the '-q' flag (quiet) which should solve your requester issue.
Sorry for forgetting to mention, the q quiet flag doesn't work in this case. Already tested that.

Code: Select all

"%ProgramFiles%\PureBasic\SDK\PureUnit\PureUnit.exe" /ignore /quiet test.pb

Re: PureUnit triggers GUI alert on fail

Posted: Wed Oct 01, 2025 9:12 pm
by freak
It is because the whole thing is not aware of modules. The macros think you are running the test code without PureUnit because they cannot see the framework procedures and so the macros fall back to a MessageRequester() for the alert.

It needs to be reworked to properly support modules.