Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Junit testcase doubt

 
vasanth raman
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to unit test the JDK?

And what a terrible method name.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic