dunit

DUnit Testing in a Midas/DataSnap project

怎甘沉沦 提交于 2019-12-06 10:42:51
问题 How does one setup DUnit Testing in a Midas/DataSnap project in Delphi 2006 Edit How does one set up a Dunit Test into a TRemoteDataModule The project wizard in Delphi 2006 does not work with TRemoteDataModule 回答1: The question doesn't entirely make sense. Unit tests are performed in a separate project, not within your DataSnap server. Generally, tests which connect to a database are integration tests rather than unit tests. What is it, exactly that you want to test? If it's utility methods

HTTP server for unit tests in Delphi

梦想的初衷 提交于 2019-12-05 04:18:12
I need to test some HTTP components in my Delphi app. I use DUnit and want to add some automation into testing. So my testing code need to start the local HTTP server, configure it (for example, prepare for connection break in 3 seconds, or to simulate low bandwidth, or to ask for login/password etc), run my unit-tests and close HTTP server. Are there some HTTP servers available exactly for Delphi/DUnit? I know that Mozilla team have such server , but it's not too easy to integrate it into DUnit. I use Indy's TIdHttpServer to serve stuff in the same process. This approach allows me to check

DUnit: How to run tests?

会有一股神秘感。 提交于 2019-12-05 01:34:55
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 public end; var Form1: TForm1; implementation {$R *.DFM} end. Now i'll add a test case to check that pushing Button1 does what it should: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private public end; var

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

心不动则不痛 提交于 2019-12-05 00:05:14
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 FastMM4.92 You have to build your DUnit GUI-testrunner with the FASTMM and ManualLeakReportingControl directive. This will enable the memoryleak items (Take a look in GUITestRunner.pas). 来源: https://stackoverflow.com/questions/685904/how-can-i-enable-the-memory-leak-tracking-with-fastmm-in-dunit

How to access fields of a TTestCase in a TTestSetup class

主宰稳场 提交于 2019-12-04 10:27:33
问题 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 put the Initialization process in the TMyTestSetup.SetUp routine to increase performance. My problem is how can I access the object I want to initialize, which is a field of my TMyTest in the TestSetup class? Is the only way to do it declaring it

Unit-testing Delphi data modules

拟墨画扇 提交于 2019-12-03 13:36:51
问题 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? 回答1: After the last question about this, I wrote a blog post about how to do it. 回答2: Some basic tips: Your DataModules should never have any references to forms or any other UI components Put the TDataSources on forms and not in your DataModules. Make sure there isn't any prompts for confirmation and operations

Increasing testability, when coding with Bold for Delphi framework

我的未来我决定 提交于 2019-12-03 04:59:32
问题 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 millions lines of code. We release to production after 4-5 weeks and after almost every release we have to do some patches for bugs we don’t found. This is of course irritating both for us and the customers. Current testing The solution is of course more

How to start unit-test old and new code?

痴心易碎 提交于 2019-12-03 01:50:32
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 application and we are a team that maintain it. The testing for now is done by one person that use it before release and report bugs. I have also set up some GUI-tests in TestComplete 6, but it often fails because of changes in the application. Bold for Delphi is used as persistance framework against the database. We all agree that unittesting is the way to

How can I test private methods with DUnit?

风格不统一 提交于 2019-11-30 11:13:55
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 to write a unit test for this class I have to make all the methods public. Is there a different way to declare the private methods so that I can still test them but they are not public? You don't need to make them public. Protected will do. Then you can subtype the class for unit testing and surface the protected methods. Example: type TAuth = class(TDataModule)

Can I write 'parameterized' tests in DUnit

我是研究僧i 提交于 2019-11-30 10:35:35
问题 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 specifying an input and expected output to a suitable test procedure, then running the test suite and getting feedback on which of the multiple runs of the test failed? (Edit: an example) For example, suppose I had two tests like this: procedure