Wednesday, 11 September 2013

How to test standard output string in other java file in Java?

How to test standard output string in other java file in Java?

So, in brief:
I have a method that is void, and prints stuff to standard output.
I have a second file that tests the output of functions against what it
should be and returns true if they all pass.
I have a makefile that checks the output of the test file to make sure
that all the tests passed.
My problem is that I don't know how to compare the void method's printed
output against what it should be in the test file. I was told to modify
the make file, but I don't know how. My other tests for methods with
return types look something like this:
private static boolean testNumFunc() {
if (MainFile.numFunc(300) == /*proper int output*/) {
return true;
}
return false;
}
How would I test a void function this way by modifying the makefile?

No comments:

Post a Comment