Test for functions which takes no parameters and returns nothing
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Deepika_Garg
Posted On:   Tuesday, June 11, 2002 06:17 AM

I am new to unit testing...I need to test a function that writes something to database through insert query.The function takes no parameters and returns nothing how to test this?

Re: Test for functions which takes no parameters and returns nothing

Posted By:   Venky_Krishna  
Posted On:   Wednesday, June 12, 2002 06:20 AM

This is a happy path test case. In your test case function, first call this inserting row method. This should have inserted a row into the database. Then do a select on it to make sure the row has actually been inserted. You can take it a step further and also delete that row. In that case, you should be able to run this test case method any number of times.


But please remember that JUnit is more useful when you test it for erroneous conditions. For example, how is the insert handled when you give it erroneous data, or if the database connection is down, or if no connection is available? What happens if some primary key / indexes are violated? Testing for the unhappy paths will make your test case more robust.


Thanks, Venky

Re: Test for functions which takes no parameters and returns nothing

Posted By:   Anonymous  
Posted On:   Tuesday, June 11, 2002 07:04 PM

Take a look at http://c2.com/cgi/wiki?UnitTestsAndDatabases

Re: Test for functions which takes no parameters and returns nothing

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, June 11, 2002 07:30 AM

With a test scaffold that does a select from the same database table?

About | Sitemap | Contact