Delphi Unit Test

Asked

Viewed 527 times

2

I am implementing Dunit in the company and my question is the following: there is some way to click the button of a "Showmessage", of a form I can, but I would like when the showmessage window appeared, I could schedule the click of this button automatically, with no user intervention. Does anyone know if it is possible to do it or has any different idea.

Thanks in advance for your cooperation.

leandro passion

  • What if instead of showmessage you create a form in the showmessage template?

  • 1

    You’re trying to use Dunit to test user interaction routines and it’s not meant to be. The xUnit concept and architecture is to test business code, routines with inputs (parameters, for example) that produce certain outputs (function return, data persistence, entity status change...). If you need to simulate user interaction because you just want to test the graphical interface, you need to find another tool. If what you want to test is the business code attached to this form, you first need to uncouple the code and then the Dunit maybe serve.

1 answer

1


procedure TFProv_Principal.BitBtn1Click(Sender: TObject);
begin
Timer1.Interval := 3000; // Tempo que a msg ficará na tela -> 3 Segs
Timer1.Enabled := True;
MessageBox(Handle, PChar(´Testando MessageBox com tempo pré-definido.´), Pchar(´Titulo´), 8224);
end;

procedure TFProv_Principal.Timer1Timer(Sender: TObject);
begin
keybd_event(VK_RETURN,0,0,0);
Timer1.Enabled := False;
end;
  • 2

    As a suggestion, in addition to posting the code, make a brief comment about how it works and leave hints on how to implement it. It would also be interesting to indicate a reading reference on the subject of the problem (if you have any).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.