Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Unit Testing/Test Case Wizard    [ Add a report in this area ]  
Report #:  21762   Status: Open
wrong constructor called
Project:  Delphi Build #:  9.0.1xxx
Version:    9.0 Submitted By:   Markus Humm
Report Type:  Basic functionality failure Date Reported:  11/28/2005 1:46:38 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   210024
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
4.00 out of 5
Total Votes: 2
Description
If you add testcases for a class which has its own constructor with some parameters the setup method of the testcase class calls the constructor of the base class instead of your own one.
Steps to Reproduce:
1. write a class with a constructor with at
   least one parameter. The class inherits
   directly from TObject.

2. make a testproject and add testcases for
   your class

3. look at the generated setup method. It will
   call create instead of create(myparam) for
   instance.
Workarounds
alter the call in such a way that it calls
your constructor instead of the inherited one from tObject.
Attachment
None
Comments

Jeremy North at 10/25/2006 6:50:33 PM -
How is it supposed to know what parameter to use in the generated code?

I don't see how this could be achieve with the wizard unless the wizard asked for what parameters to use for the constructor.

Markus Humm at 7/22/2007 9:38:25 AM -
I don't know either but as it is it's a trap for every programmer. Maybe a Create(?) should be inserted so it fails compilation and reminds the programmer to do a proper initialization himself.

Server Response from: ETNACODE01