473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to test a function ?

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
Jul 21 '05 #1
4 1329
Take a look at Nunit for testing functions and libraries.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Jul 21 '05 #2
To test out small functions like these you can download a sniplet comiler from this site

http://www.sliver.com/dotnet/SnippetCompiler/

this is very useful. try it out

Regards
Ganesh

"Agnes" wrote:
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

Jul 21 '05 #3
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" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Jul 21 '05 #4
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" <ro*****@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
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" wrote:
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" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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


Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jussi Mononen | last post by:
Hi, I'm having problems to successfully execute the test scripts on a Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up with the following error message "PARI: *** ...
5
by: Andy | last post by:
How can you unit test nested functions? Or do you have to pull them out to unit test them, which basically means I will never use nested functions. Also, same thing with private member functions...
35
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C#...
6
by: Ben Finney | last post by:
Howdy all, Summary: I'm looking for idioms in unit tests for factoring out repetitive iteration over test data. I explain my current practice, and why it's unsatisfactory. When following...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
5
by: istillshine | last post by:
When I want to test if a function foo in a .c file behaves as expected, I usually call it in my main.c in the following way. if (1) { /* test function foo */ z = foo(x, y); /* */...
4
by: istillshine | last post by:
I have a function foo, shown below. Is it a good idea to test each argument against my assumption? I think it is safer. However, I notice that people usually don't test the validity of...
3
by: JanW | last post by:
Somewhat a C++ beginner, I'm trying to make a general test function that could test unary operators (or methods) of an object of any class. Arguments are a member-pointer to the function, a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.