So I created a log function so I can see the date of every action. I now want to unittest them. Because the function uses a void, I can't test the output.
I might change the void to a String, but then the point of using it as a void would be gone!
What are my options?
public class Logger {
public static void log(String s) {
Date d = new Date();
SimpleDateFormat ft =
new SimpleDateFormat ("yyyy.MM.dd '-' hh:mm:ss");
System.out.println("[" + ft.format(d) + "]: " + s);
}
}
JUnit
@Test
public void testLoggerEmptyString() {
String s = "";
log(s);
}
Thanks :D