Skip to content

Integrating DUnit and FinalBuilder

I’ve just added unit test execution to our automated builds. Nothing too hard, there, but there are a couple of things I had to look up. First, DUnit doesn’t have a command-line switch for console vs. GUI mode; you have to use a compiler directive. So I had to add CONSOLE_TESTRUNNER to the compiler directives in the automated build. I used the Execute Program action in FinalBuilder to run the tests, set to fail if the exit code is not equal to 0. But then I found that by default DUnit doesn’t change the exit code when a test fails. The fix for this is to go into the DPR and change this code:

  if IsConsole then
    TextTestRunner.RunRegisteredTests
  else
    GUITestRunner.RunRegisteredTests;

to this:

  if IsConsole then
    TextTestRunner.RunRegisteredTests(rxbHaltOnFailures)
  else
    GUITestRunner.RunRegisteredTests;

Now everything works correctly and I have yet another way to break the build! By the way, if you haven’t already tried the DUnit integration in D2006, it’s really nice; it makes building unit tests much more convenient.

Post a Comment

Your email is never published nor shared. Required fields are marked *

Bad Behavior has blocked 1846 access attempts in the last 7 days.

Close