John R. 18 Posted April 3 I'm wondering if there is some workaround to this problem I frequently have. My test project's DPR looks like this: program tests; {$IFNDEF TESTINSIGHT} {$APPTYPE CONSOLE} {$ENDIF} {$STRONGLINKTYPES ON} uses System.SysUtils, {$IFDEF TESTINSIGHT} TestInsight.DUnitX, {$ELSE} DUnitX.Loggers.Console, DUnitX.Loggers.XML.NUnit, // <-- This line is removed from time to time by Delphi IDE {$ENDIF } DUnitX.TestFramework, // [...] But every time I add a new unit to that project and save it, the Delphi IDE decides to remove this line, and only this one: DUnitX.Loggers.XML.NUnit Is that a known problem ? Is there some workaround ? I'm using Delphi 12 Patch 1 with TestInsight 1.2.0.6 Share this post Link to post
Uwe Raabe 2057 Posted April 3 I guess that is caused by the {$ELSE} part of the TESTINSIGHT conditional. You can safely remove that: System.SysUtils, {$IFDEF TESTINSIGHT} TestInsight.DUnitX, {$ENDIF } DUnitX.Loggers.Console, DUnitX.Loggers.XML.NUnit, DUnitX.TestFramework, 1 Share this post Link to post
Stefan Glienke 2002 Posted April 5 (edited) My general advice to this is usually to move any conditional unit usage to its own unit and then only reference that unit in the dpr. Unfortunately, that is not some practice the DUnitX Expert is using. It would possibly also reduce the duplicated code generated for the dpr main every time. Edited April 5 by Stefan Glienke 1 Share this post Link to post
Vincent Parrett 750 Posted April 5 There is no generic "works for everyone" main dpr setup for dunitx - the code depends on what logging and settings you want. You typically do not want the console logger or the xml logggers when using TestInsight - and when running on a CI server you probably don't want the console logger. I guess we could move some of the generated code to another generated unit so the IDE doesn't mess with the ifdefs - I don't have time to work on it at the moment but happy to accept a PR that improves this situation. 1 Share this post Link to post
Uwe Raabe 2057 Posted April 6 16 hours ago, Vincent Parrett said: You typically do not want the console logger or the xml logggers when using TestInsight - and when running on a CI server you probably don't want the console logger. The inclusion of the units seems to do no harm. The linker probably omits them when no instance is created. It is different with TestInsight as unit TestInsight,DUnitX may not even exist. Share this post Link to post