I'm using mocking technique in DUnitX project for ShowMessage dialog.Because I don't want that ShowMessage stops test execution. I tried with this but it is not working.
unit TestMain2;
interface
uses
  DUnitX.TestFramework, Main, Vcl.Dialogs, System.SysUtils, Windows, Vcl.Forms, Winapi.Messages;
type
  TMockShowMessageHelper = class
  private
    class var FAutoProceed: Boolean;
    class var FCapturedMessage: string;
    class procedure MockShowMessage(const Msg: string);
  public
    class property AutoProceed: Boolean read FAutoProceed write FAutoProceed;
    class property CapturedMessage: string read FCapturedMessage;
  end;
  [TestFixture]
  TMyTestObject = class
  private
    procedure SimulateButtonClick;
  public
    [Setup]
    procedure Setup;
    [TearDown]
    procedure TearDown;
    [Test]
    procedure Test1;
  end;
implementation
// Mock implementation of ShowMessage
class procedure TMockShowMessageHelper.MockShowMessage(const Msg: string);
begin
  FCapturedMessage := Msg;
  if FAutoProceed then
    PostMessage(Application.Handle, WM_CLOSE, 0, 0);
end;
var
  MainFormT: TMainForm;
procedure TMyTestObject.Setup;
begin
  MainFormT := TMainForm.Create(nil);
  // Replace ShowMessage with our mock implementation
  Vcl.Dialogs.ShowMessage := TMockShowMessageHelper.MockShowMessage;
end;
procedure TMyTestObject.TearDown;
begin
  MainFormT.Free;
end;
procedure TMyTestObject.SimulateButtonClick;
begin
  MainFormT.Button1.Click;
end;
procedure TMyTestObject.Test1;
begin
  TMockShowMessageHelper.AutoProceed := True; // Set this flag to automatically proceed
  SimulateButtonClick;
end;
initialization
  TMockShowMessageHelper.AutoProceed := False; // Set the flag to default value
  TDUnitX.RegisterTestFixture(TMyTestObject);
end.
Compiler error:
E2250 There is no overloaded version of 'ShowMessage' that can be called with these arguments
How to fix this? Or is there any better way to do the same? Changing orginal unit that I'm testing is not an option.
I need to do similar for MessageDlg.
