Questions tagged [dunit]

xUnit-style unit testing for Borland Delphi programs.

DUnit is an Xtreme testing framework for Borland Delphi programs. It was originally inspired on the JUnit framework written in Java by Kent Beck and Erich Gamma, but has evolved into a tool that uses much more of the potential of Delphi to be much more useful to Delphi developers.

Source code and mailing lists are available at DUnit's Source Forge page.

89 questions
32
votes
1 answer

How can I customize the DUnit test case classes generated by the Test Case wizard?

After poking around in the files installed by Delphi, I have found a file "C:\Program Files\Embarcadero\RAD Studio\7.0\ObjRepos\en\UnitTestFrameworks.xml" This file has a number of sections for setting options that affect the test case code…
lukeck
  • 4,528
  • 3
  • 27
  • 29
30
votes
5 answers

CheckException only accepts 0-parameter methods; how do I test that other methods throw exceptions?

I'm wondering what's the best practice to test for exceptions in dunit. I am not very familiar with method pointers in Delphi. Is there any possibility to bind arguments to a method pointer so that it could be invoked without arguments. At the…
hansmaad
  • 18,417
  • 9
  • 53
  • 94
26
votes
6 answers

Measuring code coverage in Delphi

Is there any way to measure code coverage with DUnit? Or are there any free tools accomplishing that? What do you use for that? What code coverage do you usually go for? Jim McKeeth: Thanks for the detailed answer. I am talking about unit testing in…
jpfollenius
  • 16,456
  • 10
  • 90
  • 156
25
votes
5 answers

Can I write 'parameterized' tests in DUnit

I am using DUnit to test a Delphi library. I sometimes run into cases, where i write several very similar tests to check multiple inputs to a function. Is there a way to write (something resembling) a parameterized test in DUnit? For instance…
Mathias Falkenberg
  • 1,110
  • 1
  • 11
  • 25
19
votes
3 answers

Increasing testability, when coding with Bold for Delphi framework

Background I work in a team of 7 developers and 2 testers that work on a logistics system. We use Delphi 2007 and modeldriven development with Bold for Delphi as framework. The system has been in production about 7 years now and has about 1,7…
Roland Bengtsson
  • 5,058
  • 9
  • 58
  • 99
18
votes
5 answers

How to start unit-test old and new code?

I admit that I have almost none experience of unittesting. I did a try with DUnit a while ago but gave up because there was so many dependencies between classes in my application. It is a rather big (about 1.5 million source lines) Delphi…
Roland Bengtsson
  • 5,058
  • 9
  • 58
  • 99
17
votes
7 answers

How can I test private methods with DUnit?

I have a class that I am unit testing into with DUnit. It has a number of methods some public methods and private methods. type TAuth = class(TDataModule) private procedure PrivateMethod; public procedure PublicMethod; end; In order…
Charles Faiga
  • 11,665
  • 25
  • 102
  • 139
14
votes
7 answers

How to access fields of a TTestCase in a TTestSetup class

I am creating unit tests with DUnit. I have a class that takes quite a long time to initialize. I derive a class TMyTestSetup from TTestSetup and override its Setup method. This SetUp method is only called once for all the tests in my TTestCase. I…
Michael Küller
  • 3,982
  • 4
  • 22
  • 42
13
votes
3 answers

DUnit tests hierarchy

Currently I am using 2-level test hierarchy in DUnit (Test Project -> Test Case -> Test method; see example below). Is it possible to introduce 3rd level or even more levels?
kludg
  • 27,213
  • 5
  • 67
  • 118
13
votes
1 answer

How can I enable the memory leak tracking with FastMM in DUnit?

In the GUI test runner, the menu items for memory leak checking are inactive (grayed out). Is there a special switch I have not found yet to activate them? Using DUnit 9.4 (from Delphi 2009 or from the sourceforge Subversion repository) and…
mjn
  • 36,362
  • 28
  • 176
  • 378
13
votes
4 answers

Delphi unit test for a TThread with FreeOnTerminate = True

What is the best way to write a Delphi DUnit test for a TThread descendant when FreeOnTerminate = True? The TThread descendant returns a reference which I need to test for, but I can't figure out how to wait for the thread to finish in the…
Rick Wheeler
  • 1,142
  • 10
  • 22
11
votes
2 answers

Data-driven DUnit testing

The way DUnit normally works is you write some published methods, and DUnit runs them as tests. What I want to do is a little different. I want to create tests at run time based on data. I'm trying to test a particular module that processes input…
dan-gph
  • 16,301
  • 12
  • 61
  • 79
10
votes
3 answers

DUnit: How to run tests?

How do i run TestCase's from the IDE? i created a new project, with a single, simple, form: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) private …
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
10
votes
2 answers

Getting DUnit Test Coverage stats using FinalBuilder and AQTime

We have a large Delphi project (1.5 million lines of code), and we're moving to using agile processes. We already have a continous integration environment (FinalBuilder) which I've updated to include unit tests (dUnit) and code metrics…
Catharz
  • 1,105
  • 10
  • 18
10
votes
3 answers

Single-source unit tests for Free Pascal and Delphi

Is there a way to write unit tests so that they can be compiled and run both with Delphi and Free Pascal? There are different unit test frameworks for Delphi and Free Pascal, which causes duplicate work for developers who target both compilers (for…
mjn
  • 36,362
  • 28
  • 176
  • 378
1
2 3 4 5 6