Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What to test?

 
vishal sodani
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Testing Forum.
 
Richard Jensen
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vishal sodani
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use dbUnit to automate the assertion of the state information in a database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic