BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How would you unit test this?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Kyle A. Miller
Guest





PostPosted: Tue Jan 11, 2005 10:48 pm    Post subject: How would you unit test this? Reply with quote



I have a base main form which new applications inherit from to create
their main form. Part of the ancestor main form's job is to initialize
the GUI's core support and kick start the application core handled by
the main datamodule.

So let's say I want to test a method in the ancestor form called
DoSignOn, which validates the user and logs them into a historical
table. This method is called as part of the ancestor form's creation. If
I write a test case for DoSignOn, I create the form as part of the SetUp.

What is the point of testing DoSignOn or any of the other half dozen
methods which start the application up if the method to test is the
method called during objection creation, which must happen in SetUp,
which happens before the test method is called?

Each startup method has a unique responsibility in the startup chain of
events, but it's hard to test them when the methods to test are called
during object creation.

Just FYI, the inheritance chain is as follows.

TfrmBase = class(TForm); // Mother of all forms.
TfrmBaseMain = class(TfrmBase); // Mother of all main forms.
TfrmBaseMultiWinMain = class(TfrmBaseMain); // Add multiple window
management and UI support.
TfrmMain = class(TfrmBaseMultiWinMain); // The main of any application.
Back to top
Kyle A. Miller
Guest





PostPosted: Wed Jan 12, 2005 6:44 am    Post subject: Re: How would you unit test this? Also, [TestFixtureSetup]? Reply with quote



Also, in NUnit, you can mark a class method with [TestFixtureSetup].
What is the equivalent in DUnit?
Back to top
Kyle A. Miller
Guest





PostPosted: Wed Jan 12, 2005 7:05 am    Post subject: Re: How would you unit test this? Also, [TestFixtureSetup]? Reply with quote



Kyle A. Miller wrote:
Quote:
Also, in NUnit, you can mark a class method with [TestFixtureSetup].
What is the equivalent in DUnit?

Never mind on this one. I found a short, but important, piece of text in
the docs.

<quote>
TTestSetup

TTestSetup can be used when you wish to set up state exactly once for a
test case class (the SetUp and TearDown methods are called once for each
test method). For example, if you were writing a suite of tests to
exercise some database code, you might subclass TTestSetup and use it to
open and close the database before executing the suite."
</quote>

Back to top
Ritchie Annand
Guest





PostPosted: Wed Jan 12, 2005 8:08 am    Post subject: Re: How would you unit test this? Reply with quote

On Tue, 11 Jan 2005 16:48:08 -0600, Kyle A. Miller wrote:

Quote:
I have a base main form which new applications inherit from to create
their main form. Part of the ancestor main form's job is to initialize
the GUI's core support and kick start the application core handled by
the main datamodule.

So let's say I want to test a method in the ancestor form called
DoSignOn, which validates the user and logs them into a historical
table. This method is called as part of the ancestor form's creation. If
I write a test case for DoSignOn, I create the form as part of the SetUp.

You're using DUnit, I presume? :)

If you need to test something that is part of the form creation, then my
advice would be - simply do NOT set up the form in the SetUp - SetUp is
merely a convenient device for initialization of *reliable* parts, and if
something fails, you get a red light no matter what.

Do the initialization in the TestXXX method instead, or preferably in
another non-public method you call from each TestXXX method if the setup is
at all involved.

-- Ritchie Annand

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.