I have a simple class in executable JAR file:
public final class Main {
public static void main(String[] args) {
System.out.println("hello, world!");
System.exit(-1);
}
}
Now I'm trying to test this class/method:
public class MainTest {
@Test public void testMain() {
Main.main(new String[] { "something" });
}
}
Testing crashes on System.exit(0)
, and I can understand why. Now what should I do? Shall I mock System
? What is a standard approach here? Btw, maybe I should test the method "in container" (read "in JAR"), the same way we're doing it with WAR files?