<p>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?</p>
<h3>Update:</h3>
<p>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.</p>

[{'answer_id': 18516, 'author': 'Lars Truijens', 'author_id': 1242, 'author_profile': 'https://Stackoverflow.com/users/1242', 'pm_score': 6, 'selected': True, 'text': '<p><a href="http://dunit.sourceforge.net/" rel="noreferrer">DUnit</a> 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 <a href="http://www.elvenware.com/charlie/conferences/2004/talks/UnitTests/dunit/test_tools/index.html" rel="noreferrer">here</a>. DUnit comes with <a href="http://dunit.sourceforge.net/README.html" rel="noreferrer">documentation with examples</a>.</p>\n'}, {'answer_id': 18554, 'author': 'Gustavo', 'author_id': 2015, 'author_profile': 'https://Stackoverflow.com/users/2015', 'pm_score': 1, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 25018, 'author': 'PetriW', 'author_id': 1604, 'author_profile': 'https://Stackoverflow.com/users/1604', 'pm_score': 2, 'selected': False, 'text': "<p>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.</p>\n\n<p>I use delphi 2007 so I don't really know if this is available in 2006.</p>\n"}, {'answer_id': 63782, 'author': 'lukeck', 'author_id': 2189521, 'author_profile': 'https://Stackoverflow.com/users/2189521', 'pm_score': 2, 'selected': False, 'text': '<p>We do unit testing of all logic code using DUnit and use the code coverage profiler included in <a href="http://www.automatedqa.com/products/aqtime/index.asp" rel="nofollow noreferrer">AQTime</a> to check that all paths through the code are executed by the tests.</p>\n'}, {'answer_id': 99434, 'author': 'Sean Cross', 'author_id': 18517, 'author_profile': 'https://Stackoverflow.com/users/18517', 'pm_score': 3, 'selected': False, 'text': '<p>DUnit2 is available from <a href="http://members.optusnet.com.au/~mcnabp/" rel="nofollow noreferrer">http://members.optusnet.com.au/~mcnabp/</a></p>\n\n<p>DUnit2 is modified more regularly than the original dunit.  It also works on Delphi 2009.</p>\n\n<p>Try: <a href="http://sourceforge.net/projects/dunit2/" rel="nofollow noreferrer">http://sourceforge.net/projects/dunit2/</a> - it moved as the original author Peter McNab passed away several years ago. Still some activity on the dunit mailing list.</p>\n'}, {'answer_id': 687590, 'author': 'mjn', 'author_id': 80901, 'author_profile': 'https://Stackoverflow.com/users/80901', 'pm_score': 4, 'selected': False, 'text': '<p>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</p>\n\n<ol>\n<li><a href="http://sourceforge.net/projects/fastmm/" rel="nofollow noreferrer"><strong>FastMM4</strong></a> integration: Unit tests will automatically detect memory leaks (and other things), works with DUnit 9.3 and newer</li>\n<li><a href="http://sourceforge.net/projects/openctf/" rel="nofollow noreferrer"><strong>OpenCTF</strong></a> is a \'component test\nframework\' based on DUnit, it\ncreates the tests dynamically for\nall components in the project\'s\nforms, frames and datamodules, and\ntests them using customized rules (open source)</li>\n</ol>\n'}, {'answer_id': 2352519, 'author': 'mmmm', 'author_id': 85592, 'author_profile': 'https://Stackoverflow.com/users/85592', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n\n<p>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.</p>\n'}, {'answer_id': 5653865, 'author': 'Arnaud Bouchez', 'author_id': 458259, 'author_profile': 'https://Stackoverflow.com/users/458259', 'pm_score': 3, 'selected': False, 'text': '<p>You could take a look at the unit testing classes available in our <a href="http://synopse.info/fossil/finfo?name=SynCommons.pas" rel="noreferrer">SynCommons open source unit</a>. It\'s used in our Open-Source framework for all regression tests. It\'s perhaps not the best, but it\'s worth taking a look at it. </p>\n\n<p>See <a href="http://blog.synopse.info/post/2010/07/23/Unit-Testing-light-in-Delphi" rel="noreferrer">http://blog.synopse.info/post/2010/07/23/Unit-Testing-light-in-Delphi</a> </p>\n\n<p>In order to implement an unit test, you just declare a new test case by creating a class like this:</p>\n\n<pre><code>type\n  TTestNumbersAdding = class(TSynTestCase)\n  published\n    procedure TestIntegerAdd;\n    procedure TestDoubleAdd;\n  end;\n\nprocedure TTestNumbersAdding.TestDoubleAdd;\nvar A,B: double;\n    i: integer;\nbegin\n  for i := 1 to 1000 do\n  begin\n    A := Random;\n    B := Random;\n    CheckSame(A+B,Adding(A,B));\n  end;\nend;\n</code></pre>\n\n<p>Then you create a test suit, and run it.</p>\n\n<p>In the up-to-come 1.13 version, there is also a new logging mechanism with stack trace of any raised exception and such, just like MadExcept, using .map file content as source.</p>\n\n<p>It\'s now used by the unit testing classes, so that any failure will create an entry in the log with the source line, and stack trace:</p>\n\n<pre><code>C:\\Dev\\lib\\SQLite3\\exe\\TestSQL3.exe 0.0.0.0 (2011-04-13)\nHost=Laptop User=MyName CPU=2*0-15-1027 OS=2.3=5.1.2600 Wow64=0 Freq=3579545\nTSynLogTest 1.13 2011-04-13 05:40:25\n\n20110413 05402559 fail  TTestLowLevelCommon(00B31D70) Low level common: TDynArray "" stack trace 0002FE0B SynCommons.TDynArray.Init (15148) 00036736 SynCommons.Test64K (18206) 0003682F SynCommons.TTestLowLevelCommon._TDynArray (18214) 000E9C94 TestSQL3 (163) \n</code></pre>\n\n<p>The difference between a test suit without logging and a test suit with logging is only this:</p>\n\n<pre><code>procedure TSynTestsLogged.Failed(const msg: string; aTest: TSynTestCase);\nbegin\n  inherited;\n  with TestCase[fCurrentMethod] do\n    fLogFile.Log(sllFail,\'%: % "%"\',\n      [Ident,TestName[fCurrentMethodIndex],msg],aTest);\nend;\n</code></pre>\n\n<p>The logging mechanism can do much than just log the testing: you can log recursive calls of methods, select the information you want to appear in the logs, profile the application from the customer side, writing published properties, TList or TCollection content as JSON into the log content, and so on...</p>\n\n<p>The first time the .map file is read, a .mab file is created, and will contain all symbol information needed. You can send the .mab file with the .exe to your client, or even embed its content to the .exe. This .mab file is optimized: a .map of 927,984 bytes compresses into a 71,943 .mab file.</p>\n\n<p>So  this unit could be recognized as the natural child of DUnit and MadExcept wedding, in pure OpenSource. :)</p>\n\n<p>Additional information is <a href="http://synopse.info/forum/viewtopic.php?id=296" rel="noreferrer">available on our forum</a>. Feel free to ask. Feedback and feature requests are welcome! Works from Delphi 6 up to XE.</p>\n'}, {'answer_id': 19513500, 'author': 'Harriv', 'author_id': 7735, 'author_profile': 'https://Stackoverflow.com/users/7735', 'pm_score': 3, 'selected': False, 'text': '<p>There\'s a new unit testing framework for modern Delphi versions in development: <a href="https://github.com/VSoftTechnologies/DUnitX" rel="noreferrer">https://github.com/VSoftTechnologies/DUnitX</a></p>\n'}]
['https://Stackoverflow.com/questions/18291', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1461/']