Action to run Delphi DUnitX tests never returns

We have a unit that we include in all of the Unit tests that automagically configures the output exe depending on the target (debug/release) and whether we want DUnitX formatted output.

Regardless the strange thing is that it is an intermittent problem. We have file access mocked in classes that read from INI files for instance. I’ll take a look at the anti virus settings though.

FWIW, here is the code for the unit we include, makes configuring unit tests much, much simpler :slight_smile:

unit uRunDUnit;

// Important: copy the following lines to the top of the *.DPR file
{$IFDEF RELEASE}
{$APPTYPE CONSOLE}
{$ENDIF}


// DEFINE THE following Symbol to get NUnit XML output
//XMLOUTPUT

interface

uses
  SysUtils,
  Forms,
  TestFramework,
{$IFDEF RELEASE}
  {$IFDEF XMLOUTPUT}
    VSoft.DUnit.XMLTestRunner,
    VSoft.MSXML6;
  {$ELSE}
    FinalBuilder.XMLTestRunner;
  {$ENDIF XMLOUTPUT}
{$ELSE}
  {$IFNDEF TESTINSIGHT}
  GUITestRunner;
  {$ELSE}
  TestInsight.DUnit; // use the TestInsight runner if the project has been setup to run this way
  {$ENDIF TESTINSIGHT}
{$ENDIF RELEASE}

{$IFDEF RELEASE}
var
  OutputFile: string;
  ConfigFile: string;
{$ENDIF}

procedure RunUnitTests;

implementation

procedure RunUnitTests;
begin
{$IFDEF RELEASE}
  OutputFile := ChangeFileExt(Application.ExeName, '.xml');

  if ConfigFile <> '' then
  begin
    RegisteredTests.LoadConfiguration(ConfigFile, False, True);
  end;
  if ParamCount > 0 then
    OutputFile := ParamStr(1);
  {$IfDef XMLOUTPUT}
    PrintReportToConsole := False;
    TXMLTestListener.RunRegisteredTests(OutputFile);
  {$else}
    FinalBuilder.XMLTestRunner.RunRegisteredTests(OutputFile);
  {$endif XMLOUTPUT}
{$ELSE}
  Application.Initialize;
  {$IFNDEF TESTINSIGHT}
    TGUITestRunner.RunRegisteredTests;
  {$ELSE}
    TestInsight.DUnit.RunRegisteredTests;
  {$ENDIF TESTINSIGHT}
{$ENDIF RELEASE}
end;

end.