aspose file tools*
The moose likes Testing and the fly likes Junit testcase doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Junit testcase doubt" Watch "Junit testcase doubt" New topic
Author

Junit testcase doubt

vasanth raman
Greenhorn

Joined: Aug 13, 2009
Posts: 24
how to write a test case for this method
public class Firstjava {
public void multiply(int x, int y) {
System.out.println("x"+x+"y"+y);
}


}
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why would you want to unit test the JDK?

And what a terrible method name.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I don't really see how he is testing the JDK but I totally agree with your comment about the method name.

If you want to test standard output you can set a different PrintStream with System.setOut() in your setup method and remove it in your after method. Then in the test methods you can compare the expected output with the toString of the PrintStream.

// Edit: I don't think that all PrintStreams will work but ByteArrayOutputStream will work.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Junit testcase doubt
 
Similar Threads
Why does x=x++ cause infinite loop?
how to access the elements of multidimension array using for each loop?
small swapping problem please please reply!!!!!
can anybody tell how the counting in loop happens for this program?
question about variables changed inside methods