RE: [Comunit-users] Test Cases using COMUnit
Brought to you by:
exortech,
kimgrasman
|
From: <Jam...@ox...> - 2002-04-18 10:16:52
|
Hi,
I'm still fairly new to this, but:
1) In this situation, I think that you should be testing for the desired
effects of the procedure. e.g. If the procedure is
AddThingToDatabase(thing), you should call it with a particular 'thing', and
then test that it got added to the database correctly. Tests should be made
with various (pathological?) cases of 'thing' so that you know that the
error handling is OK, as well.
2) Can you put an error handler in the Test case so that the test passes if
the correct error comes to the error handler, but fails if no error or the
wrong error is thrown.
e.g.
Public Sub TestDatabaseManagerErrors(oTestResult As TestResult)
Dim dic as New Dictionary
OnError Go To handler:
Dim DB as New DatabaseManager
' Expect Error
DB.Init dic
oTestResult.AddFailure "DatabaseManager.Init with empty dictionary did
not throw an Error"
Exit Sub
handler:
oTestResult.AssertEqualsLong dbErrInvalidDictionary, Err.Number, _
"DatabaseManager.Init with empty dictionary threw an
incorrect Error"
End Sub
Oh! I just read your email properly, and you say you can't test for the
error there. Obviously this would kill my suggestion, but why is this? As
long as you are expecting a particular error, you can test for it, can't
you? If you aren't expecting it, then don't have the error handler. There's
always the possibility of having multiple error handlers, one installed for
each section of the procedure, almost like a 'proper' try/catch system :-).
If anyone wants to correct me on any of this, please do. I've really only
just started using this COMUnit stuff, but I like to at least try and help.
James Chaldecott
Software Engineer
Oxford Instruments Analytical
-----Original Message-----
From: Mercadence [mailto:raj...@me...]
Sent: 18 April 2002 07:16
To: com...@li...
Subject: [Comunit-users] Test Cases using COMUnit
Hi Guys,
I have following questions:
1. How to write COMUnit test cases for procedures without return values ?
Since the test
case's assert method is based on return values.
Currently I am considering such test case to be successful if no error is
raised in the
procedure.
2.In some cases, custom errors are raised inside the procedure so that the
error is escalated to the client application.
For example,if the Dictionary object that is passed to DatabaseManager
Object doesn't contain all the keys required to open a connection, error is
raised rather than trying to open the DB connection with insuffecient
parameters.
In a test case to test whether the correct error is raised in the procedure,
(situations like above) test case reports it as an error though we are
expecting an error there.
We should not handle those errors in the test case since other errors with
same error number will go unnoticed.How to handle this situation ?
You help will be highly appreciated.
Thanks,
Rajesh.
_______________________________________________
Comunit-users mailing list
Com...@li...
https://lists.sourceforge.net/lists/listinfo/comunit-users
+++ Virus-scanned by Messagelabs for Oxford Instruments +++
### OXFORD INSTRUMENTS http://www.oxford-instruments.com/ ###
Unless stated above to be non-confidential, this E-mail and any
attachments are private and confidential and are for the addressee
only and may not be used, copied or disclosed save to the addressee.
If you have received this E-mail in error please notify us upon receipt
and delete it from your records. Internet communications are not secure
and Oxford Instruments is not responsible for their abuse by third
parties nor for any alteration or corruption in transmission.
|