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 How to write JUnit for Void method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
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: 684


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, OCPJWSD Java Developer,My Blog
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

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?


PM Me If You Want to get Urgent Help on Java Programming
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

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: 485

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: 30057
    
149

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]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to write JUnit for Void method
 
Similar Threads
how to test void method.
How do I write a Junit test for my main method in the class
testing void methods which insert in database
Q 4 J. B. Rainsberger (2): preconditions for a recipe
Junit in Queries