Unit testing

January 26th, 2007

This list will evolve over time with useful items for unit testing in Delphi.

DUnit IDE integration

This is an early release. There are still some bugs to be worked out. This package is intended for BDS2006 but may also work on earlier version of Delphi. Please see the instructions on how to use it:

Building:

The package is setup use the JEDI JCL. I handled this by creating an environment variable $(JCL) to point to the directory in which I have the jcl installed. Do this or overwrite the search path in the package options to agree with your environment.

Using this package:

Either open an existing project or begin a new one. Then:

  • Open the project manager and add a new DLL project.
  • In the DLL source add this define: {$DEFINE TESTPROJECT}
  • Export the RegistedTests function from TestFramework.pas with the name “Test”
  • Add your test cases to this new DLL project.
  • The default keyboard shortcut is ALT+CTRL+;. You can also run tests by Project\Test Project

When you run your tests a new tab in the message window will open called “Tests”. You will find the test output there. Double-clicking on any failures will take you to that line in the specified file (see known issues about this).

Known issues:

  • Sometimes the stack trace shows a test failure as occuring in TestFramework.pas instead of the unit in which the test resides.

Here is this the code: dunitide100.zip

DUnit console runner

This implementation of the DUnit console runner is intended to work like the NUnit console runner. The xml output from XMLTestRunner.pas has been altered to produce results similar to that of the NUnit console runner. Useful if you have to use both DUnit and NUnit in the same build cycle.

Here is the code: dunit-console.rar

  1. Luis
    August 26th, 2009 at 06:01 | #1

    Hi.

    Any chance of getting your console runner working with Delphi 2007 and the integrated DUnit?

    Thanks.

  2. March 26th, 2010 at 02:26 | #2

    Awesome post. Keep more information like this coming!

  3. March 27th, 2010 at 07:39 | #3

    I recently came accross your blog and have been reading along. I thought I would leave my first comment.
    I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

  4. May 14th, 2010 at 03:14 | #4

    Anyway - All are working :)

  5. May 25th, 2010 at 20:46 | #5

    thank you for showing how unit testing should be done.

  6. May 27th, 2010 at 04:40 | #6

    Thanks for posting such useful items. I’ve been reading his blog with much interest. He’s certainly raised my awareness. This post is Well Organized and Informative.

  7. June 15th, 2010 at 00:13 | #7

    I came accross your blog and have been reading along. I thought I would leave my first comment.
    I dont know what to say except that I have enjoyed reading. Nice blog.

  8. June 21st, 2010 at 23:31 | #8

    Simple and informative post thanks, keep walking.

  9. July 2nd, 2010 at 02:53 | #9

    sO

  10. July 2nd, 2010 at 02:53 | #10

    so, what was the outcome of the testing.?

  11. July 2nd, 2010 at 13:19 | #11

    well then yes. I agree with you lifestyle design/

  12. July 9th, 2010 at 18:29 | #12

    I came accross your blog and have been reading along.

  13. July 27th, 2010 at 18:53 | #13

    it was a wonderful chance to visit this kind of site and I am happy to know. thank you so much for giving us a chance to have this opportunity!

  14. July 30th, 2010 at 01:36 | #14

    I’ve been reading his blog with much interest. Nice blog. I will keep visiting this blog very often.

  1. November 21st, 2006 at 14:37 | #1
  2. August 19th, 2009 at 00:35 | #2

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word