how to test a function ?

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

I create an object named Number , with the function numtowords.
i input '100' as parameter, It will return "one hundred".
However, any simple way to test this object ????
I only know the old way [create a form, textbox, button to test the program]
Any suggestion ?
Thanks
 
I would agree with Ray... using NUnit is the best way to test your function.
Look for boundary conditions, likely issues, situations that may vary (white
box) and craft a series of calls. Code the calls in a class flagged with
NUnit attributes. NUnit calls the class, which calls your code. The test
class gets the values back and check for the correct translation. If a
failure is detected, your NUnit class throws an exception, and NUnit itself
catches it to show you how many errors were detected.

It is simple and elegant.

see www.nunit.org

--- Nick
 
Execute a query that returns a recordset with a known number of records then
assert that the record count is equal to a specific number.


rodchar said:
Can anyone give me some examples of assertions I can make? Like I have a
datalayer project, what are some assertions I can make to test my datalayer
or am I missing the point?

Nick Malik said:
I would agree with Ray... using NUnit is the best way to test your function.
Look for boundary conditions, likely issues, situations that may vary (white
box) and craft a series of calls. Code the calls in a class flagged with
NUnit attributes. NUnit calls the class, which calls your code. The test
class gets the values back and check for the correct translation. If a
failure is detected, your NUnit class throws an exception, and NUnit itself
catches it to show you how many errors were detected.

It is simple and elegant.

see www.nunit.org

--- Nick

Agnes said:
I create an object named Number , with the function numtowords.
i input '100' as parameter, It will return "one hundred".
However, any simple way to test this object ????
I only know the old way [create a form, textbox, button to test the program]
Any suggestion ?
Thanks
 
Back
Top