How to activate TGUITestRunner from DUnit test?

The TGUITestRunner form represents the results of the DUnit test and is created once by the procedure GUITestRunner.RunTest

:

procedure RunTest(test: ITest);
begin
  with TGUITestRunner.Create(nil) do
  begin
    try
      Suite := test;
      ShowModal;
    finally
      Free;
    end;
  end;
end;

      

I want to expand it at runtime by writing colored status messages. This is possible because the status messages at the bottom of the GUI are placed in TRichEdit. So I need to get a pointer to this form somewhere in my TTestCase.

Can I do this without fixing the DUnit code? Maybe you can recommend a hack?

+3


source to share


1 answer


A "decoupled" way to do this might be to use some "inline codes" inside your status messages:

Status('<blue>Testing');

      



Within the dUnit test environment, you can check if the start character of the status message is "<" and extract arguments like color or whatever, and then modify dUnit to handle it.

This way your tests will still run on the unmodified dUnit tester. After a few years, you can move on to the latest dUnit test and I don't recommend changing any API changes or trying to access test runner objects. The API and the things you can see from the test are strictly controlled on purpose. This is the principle of good object-oriented design that the creators of jUnit / xUnit / dUnit strongly believe.

+1


source







All Articles