IntelliJ Java IDE
The moose likes Testing and the fly likes How to write JUnit for Void method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Reply Bookmark "How to write JUnit for Void method" Watch "How to write JUnit for Void method" New topic
Author

How to write JUnit for Void method

Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 666


Hi All,

I am working on Junit test case and we have lot of void return type methods. I want to know how can I test and write JUnit for void return type method.



Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5 Java Developer,My Blog
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 110

Nishan Patel wrote:
Hi All,

I am working on Junit test case and we have lot of void return type methods. I want to know how can I test and write JUnit for void return type method.




What do you expect from those void methods?


My Blog - Java SE Quick Downloads
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 666

Hi,

I am doing database insert and update which actually return void so I just want to know how can I find whether is it working fine or not.. ?
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 427

In HashMap we have clear method right, how do you test it? You know what happens when we called that method. Just test it by iterating over it. If you found any element clear method is wrong or else it's fine. Like that you have to do.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 23644

Nishan Patel wrote:Hi,

I am doing database insert and update which actually return void so I just want to know how can I find whether is it working fine or not.. ?

Have your test do a select to see if the database is correct.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 666

Jeanne Boyarsky wrote:
Nishan Patel wrote:Hi,

I am doing database insert and update which actually return void so I just want to know how can I find whether is it working fine or not.. ?

Have your test do a select to see if the database is correct.


Yes, we have insert, update, delete and select from db.

 
 
subject: How to write JUnit for Void method
 
Threads others viewed
How do I write a Junit test for my main method in the class
testing void methods which insert in database
Junit in Queries
how to test void method.
Q 4 J. B. Rainsberger (2): preconditions for a recipe
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture