Is it
possible to check, through JUnit testing, if the method System.out.println("One, Two"),
actually prints One, Two?
A better
idea would be to change your application to be more testable by not using System.out
directly.
If
the method you are trying to test is designed to write output for end users, modify it
or the enclosing class so that the destination OutputStream or PrintWriter or whatever
is a parameter.On the other hand, if
the method is producing log output, use a proper logging framework ... and consider
whether it is worthwhile to unit test the log output at
all.
No comments:
Post a Comment