When testing code I have the source files in "C:\delphi\test" subfolders. Once I am happy of the tests I copy the code into "C:\delphi\production" and compile.

When testing code I have the source files in "C:\delphi\test" subfolders. Once I am happy of the tests I copy the code into "C:\delphi\production" and compile.

In order to double check I have migrated the code correctly and the code in production is not broken, I would like to run the same tests for the code in "C:\delphi\production" too.
In order to do so I thought it was a good idea to set up two Build configurations in the DUnit Project file: "Test" and "Production" and then via compiler directive $IfDef to connect the units to the Project in the following way:


program DUnitTestProject;

uses
  Vcl.Forms,
  SysUtils, System.Classes,
  .....
  {$ifdef Test}
    unit1 in 'C:\delphi\test\abc\unit1u.pas',
    unit2 in 'C:\delphi\test\abc\unit2u.pas';
    .....
  {$endif}
  {$ifdef production}
    unit1 in 'C:\delphi\production\abc\unit1u.pas',
    unit2 in 'C:\delphi\production\abc\unit2u.pas';
  {$endif}
.....

this way there is no need to keep two separate DUnit projects with the same tests with all the drawbacks, it is sufficient to switch the build configuration in the IDE Project Manager.
Is my approach correct/viablle ?

Comments

  1. Bert Verhees Like Kevin Powick said both Git and Mercurial have good and bad sides, use whichever you prefer. SourceTree from Atlassian is good GUI client that has built in support for both.

    ReplyDelete
  2. Leonardo Herrera I feel more comfortable to have files for testing purposes. It allows me to focus on a smaller portion of code at a time and in addition I feel the production code is in a safe place.
    Kevin Powick I haven't looked into the merge feature but as far as I can tell from you it sounds promising. I will go into details. Thank you everybody for the answers.

    ReplyDelete

Post a Comment