Question

I have a DUnit project that won't compile as Console if I add some units.
The Project (dpr) is created by the Wizard and CONSOLE_TESTRUNNER is defined.

{$IFDEF CONSOLE_TESTRUNNER}
{$APPTYPE CONSOLE}
{$ENDIF}

begin
  Application.Initialize;
  if IsConsole then // <-- IsConsole is set to False.
    with TextTestRunner.RunRegisteredTests do
      Free
  else
    GUITestRunner.RunRegisteredTests;
end.

The units that make it fail include some VCL components but no tests are run on them.
I've even tried to set the Linker Option but it made no difference.
Did someone experience a similar issue?
Just for clarification: This project is Win32 in Delphi 2010.

Was it helpful?

Solution

That code works just fine for me. I can think of two reasons why Delphi is not producing a console app:

  1. CONSOLE_TESTRUNNER is not defined.
  2. You have {$APPTYPE GUI} somewhere in your project's code.

I'm reasonably confident that item 2 above is the reason for your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top