views:

3100

answers:

9

Hi,

I'm wondering how the few Delphi users here are doing unit testing, if any ? Is there anything that integrates with the IDE that you've found works well ? If not, what tools are you using and do you have or know of example mini-projects that demonstrate how it all works ?

+17  A: 

DUnit is a xUnit type of unit testing framework to be used with win32 Delphi. Since Delphi 2005 DUnit is integrated to a certan point into the IDE. Other DUnit integration tools for the Delphi IDE can be found here. DUnit comes with documentation with examples.

Lars Truijens
+1  A: 

We tried to use DUnit with Delphi 5, but it didn't work well. Specially if you are implementing COM interfaces, we found many dependencies to setup all the test infrastructure. I don't know if the test support has improved in newer versions.

Gustavo
A: 

I forgot to mention that I'm using BDS 2006 Pro, though I occasionally drop into Delphi 7, and of course others may be using other versions.

Drew Gibson
+1  A: 

I've inherited a huge, and completely untested, Kylix codebase at work. To try and introduce some consistent unit testing I wrote my own small unit testing framework based on xUnit in that it has the notion of Suites and Cases. Pretty simple but it works.

Until I read this thread I hadn't heard of DUnit - it doesn't seem to come up on Google searches. Will give that a go.

Looking at the last-update-dates on the DUnit pages linked to it just illustrates the lack of activity on the Pascal/Delphi/Kylix front.

Steve
+2  A: 

Usually I create a Unit test project (File->New->Other->Unit Test->Test Project). It contains the stuff I need so it's been good enough so far.

I use delphi 2007 so I don't really know if this is available in 2006.

PetriW
+2  A: 

We do unit testing of all logic code using DUnit and use the code coverage profiler included in AQTime to check that all paths through the code are executed by the tests.

Luke CK
+5  A: 

DUnit2 is available from http://members.optusnet.com.au/~mcnabp/

DUnit2 is modified more regularly than the original dunit. It also works on Delphi 2009.

Sean Cross
DUnit2 is now hosted on GitHub at http://github.com/graemeg/dunit2 by Graeme Geldenhuys.
marius
+1  A: 

There are some add-ons for DUnit, maybe this is worth a new entry on SO. Two which I can put on the list now are

  1. FastMM4 integration: Unit tests will automatically detect memory leaks (and other things), works with DUnit 9.3 and newer
  2. OpenCTF is a 'component test framework' based on DUnit, it creates the tests dynamically for all components in the project's forms, frames and datamodules, and tests them using customized rules (open source)

alt text

mjustin
+1... Definitely worth the update, that's what SO is all about :)
Drew Gibson
+1 link: http://sourceforge.net/projects/openctf/
marius
+2  A: 

We have two approaches, first we have Dunit tests that are run buy the developers - these make sure that the code that has just been changed still works as before. The other approach is to use CruiseControl.NET to build executables and then run the dunit tests everytime a change is made, to ensure that there are no unintended consequences of the change.

Much of our codebase has no tests, so the automatic tests are a case of continuous development in order to ensure our applications work as we think they should.

Mmarquee