How to set up a Continuous Integration Server with Delphi, dUnit and Teamcity

If you want to set up Teamcity with Delphi you have to take care of several important issues :

You can run a build with the msbuild-runner, but the Delphi commandline-compiler needs additional Environment Variables :

  1. APPDATA : this is where EnvOptions.proj is saved, without it Delphi cannot compile anything, the Problem is that this is installed under the Config-Dir of the User who installed Delphi
    Values can be :
    German Win2003 – D2007 : C:\Dokumente und Einstellungen\<USER>\Anwendungsdaten\Borland\BDS\5.0
    English Windows7 -D2010: C:\Users\<USER>\AppData\Roaming\CodeGear\BDS\7.0
    etc.
  2. BDS – where Delphi is stored e.g. (for Delphi 2007)  C:\Programme\CodeGear\RAD Studio\5.0
  3. BDSCOMMONDIR – e.g. (for Delphi 2007) C:\Dokumente und Einstellungen\All Users\Dokumente\RAD Studio\5.0

In Build file path you just need to add the <Project>.dproj File and your done if you just want to build the executable.

This alone already helped us to ensure that we always have at least all the source-files which are needed to compile the project, which wasn’t always the case before.

If you want Teamcity to also to run your Unit-tests then you have some extra work to do :

  1. Create a new Teamcity project with all the configuration from above e.g. <Project>-Test
    1. Then you need my adapted Console-Runner for DUnit, which emits the necessary infos for Teamcity.
      Use this instead of the standard console-Runner from DUnit
      e.g. change the Source of your Test-Exe Project to

      Application.Initialize;
      if IsConsole then
       TeamCityTestRunner.RunRegisteredTests
       else
       GUITestRunner.RunRegisteredTests;
  2. Create a batch-file which calls the compiled Unit-test Exe and call it with Teamcity

and there you have it – a working integration of Delphi,  DUnit  and TeamCity.

Now if i only had a sure-fire way how to make all of the old GUI-centered Code testable so that i could switch to some Agile Practice like TDD …

TeamCityTestRunner

8 comments on “How to set up a Continuous Integration Server with Delphi, dUnit and Teamcity

  1. Very nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed surfing around your blog posts. After all I’ll be subscribing to your rss feed and I hope you write again soon!

  2. I know this is a little out of date now but are you able to give some info on how you set up DUnit under Team City? I have adopted a number of Delphi projects and want to set up CI for them but have got stuck on this point.

  3. Great article! Do you know how we can get some coverage statistics after running the unit tests? We are trying to use Discover 2.9

  4. HI
    Nenad the expert is currently in the jungle – might take a while till he answers ;)
    for .net projects we include the coverage reports as custom HTML Reports in Teamcity.

    A) add them as artifact
    B) configure them as HTML Page in Teamcity

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>