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
6
votes
1 answer

How to deal with tangled uses dependencies in order to start unit testing?

I have a messy Delphi 7 legacy system to maintain and develop. I am already reading "Working effectively with legacy code" and I like this book very much. In order to start following the advices in the book, I created a test project and tried to…
Escape Velocity
  • 729
  • 1
  • 8
  • 21
6
votes
1 answer

How to use the XPObserver unit contained in dunit's DUnitWizard, to implement an observer pattern, or even a MVC pattern?

There are good examples of Observer pattern in Delphi, thanks to the wise questions & answers on Stackoverflow, such as Best way to implement observer pattern in Delphi and Are there any Videos/Screen casts or other resources on how to use…
SOUser
  • 3,802
  • 5
  • 33
  • 63
5
votes
1 answer

What can cause the compiler not to produce a console output

I have a DUnit project that won't compile as Console if I add some units. The Project (dpr) is created by the Wizard and CONSOLE_TESTRUNNER is defined. {$IFDEF CONSOLE_TESTRUNNER} {$APPTYPE CONSOLE} {$ENDIF} begin Application.Initialize; if…
Tobias R
  • 928
  • 8
  • 22
5
votes
2 answers

(How) Can I use FutureWindows with standard file open dialogs?

I've been trying to use tomazy's FutureWindows infrastructure (see his answer at Delphi GUI Testing and Modal Forms or the home of the tool at https://github.com/tomazy/DelphiUtils), but would like to know if and how can it be used with standard…
DelphiUser
  • 419
  • 4
  • 12
5
votes
2 answers

Can I call ToolsAPI from code in the DUnit GUITestrunner?

Is there a way to initialize the global variable BorlandIDEServices in ToolSAPI unit so that it can be used from the DUnit GUITestrunner code? procedure TGUITestRunner.FailureListViewClick(Sender: TObject); var Project: IOTAProject; begin if…
mjn
  • 36,362
  • 28
  • 176
  • 378
5
votes
3 answers

Unit-testing Delphi data modules

If all the business logic is present in a datamodule (TSQLDataSets and TDataSetProviders) how would you refactor the code to make the application more appropiate for unit testing?
Tihy
5
votes
2 answers

Where can I find an introduction to using DUnit with Delphi 2007 or newer?

I'm new to using and writing unit tests, but I've become convinced that they can help me write better code and ultimately save me time. I understand that DUnit is well integrated into Delphi 2006 and newer. Does anyone know of any good resources for…
Mick
  • 13,248
  • 9
  • 69
  • 119
5
votes
3 answers

Delphi Mocks – Is it possible to use ‘VAR’ or ‘OUT’ arrangements in a function that is been mocked with a ‘WillReturn’?

I have just started to use Delphi-Mocks with my dunit tests but it has little or no documentation. The Problem is: I am trying to write a test ‘Test_LogonUser_CheckPwd_GOOD_PASSWORD’ But I am not sure how to mock out the function …
Charles Faiga
  • 11,665
  • 25
  • 102
  • 139
5
votes
5 answers

How can I test a Singleton class with DUnit?

Or it's better to use another Design Pattern?
Daniel Grillo
  • 2,368
  • 4
  • 37
  • 62
4
votes
3 answers

How to see the Status messages in DUnit GUI from all the test cases at once?

You can use TAbstractTest.Status procedure to show some debug messages in DUnit GUI during your tests. But when I run the group of tests, I can see only the status messages from the last executed test. Can I see the complete log somehow, without…
Andrew
  • 3,696
  • 3
  • 40
  • 71
4
votes
2 answers

How can I disable DUnit tests by name programmatically?

For integration tests, I created a DUnit test suite which runs once for every version of a third party component (a message broker). Unfortunately, some tests always fail because of known bugs in some versions of the tested component. This means the…
mjn
  • 36,362
  • 28
  • 176
  • 378
4
votes
0 answers

Mocking the FireDAC

I just entered the Delphi's Unit Testing area - never have done it in Delphi. The things went fine until I came to database connection and queries. I am using TFDConnection and TFDQuery in data access classes. I found an article stating that for…
Paul
  • 25,812
  • 38
  • 124
  • 247
4
votes
2 answers

Delphi 7 Dunit checks after StopExpectingException are not working as I expect

The below code works fine, the calc... generates an exception, comment it out or change calc... to not throw and exception and the test fails. StartExpectingException(exception); calcMembersPIPEndDate(EncodeDate(2005,01,01),true); …
Jason Chapman
  • 88
  • 1
  • 5
4
votes
5 answers

Why does 'uses unit' disappear when I had a new unit?

I have a Unit test project for my Application using DUnit framework. This project have a unit surrounded by a $IFDEF to output test-results in a xml file instead of the gui or just command line. XML_OUTPUT define is enabled by switching the Build…
TridenT
  • 4,879
  • 1
  • 32
  • 56
4
votes
1 answer

Should I include DUnit units into my Delphi 7 project?

I have a legacy project written for Delphi 7. I'm about to integrate a bunch of new code into it which includes a test suite using DUnit. DUnit it not a part of Delphi 7 (it has been integrated later), so here's the question: should I include DUnit…
kostix
  • 51,517
  • 14
  • 93
  • 176