File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes What to test? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "What to test?" Watch "What to test?" New topic
Author

What to test?

vishal sodani
Ranch Hand

Joined: Aug 26, 2000
Posts: 127
In the application I m developing in VB,I have many classes which have functions like insert,which basically takes data entered in UI,and sends it to database through a data object.Should I write unit tests for such functions also ie insert
I had a problem,some data was not going correctly,and ten i thought if I had unit test,(which I have not yet used),I would have found the error,much quickly.
opinions invited,
thanks
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Moving to the Testing Forum.
Richard Jensen
Ranch Hand

Joined: May 14, 2003
Posts: 67
Originally posted by vishal sodani:
In the application I m developing in VB,I have many classes which have functions like insert,which basically takes data entered in UI,and sends it to database through a data object.Should I write unit tests for such functions also ie insert
I had a problem,some data was not going correctly,and ten i thought if I had unit test,(which I have not yet used),I would have found the error,much quickly.
opinions invited,
thanks

Is your UI a graphical user interface (GUI)? Most XP practitioners recommend writing very thin GUIs that drive objects that can be tested more easily with frameworks like JUnit.
For database testing they might also suggest the notion of Mock Objects. The goal is to make your unit tests run quickly, and databases may slow this process down.
Of course, you need to actually go to the database with some of your tests to make sure that layer is correct.


Richard
N 37 33 W 122 18
vishal sodani
Ranch Hand

Joined: Aug 26, 2000
Posts: 127
Actually what I want to know is how to test that data,correct data ie, has been inserted or updated into the database.One way is to issue select statement,any other way
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
If you really want to test wether the correct data got inserted/updated, there is no other way I am aware of.
If it would suffice to know wether your classes issue the correct select/update statement (without the actual need to let it process by the database), you could go with the mock approach.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
You can use dbUnit to automate the assertion of the state information in a database.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What to test?
 
Similar Threads
Cross reference (function) Junit test
insert query not executing..
Non J2EE transactional management in Java
JUnit tests on the database CRUD functions.
Unit testing class that deals with file I/O