Main { public Main(PrintWriter outWriter, PrintWriter errWriter, InputStream inStream) { this.outWriter = outWriter; this.errWriter = errWriter; this.inStream = inStream; } Main(PrintWriter outWriter, PrintWriter errWriter, InputStream inStream); static void main(String[] args); int format(String... args); static CommandLineOptions processArgs(String... args);  }
@Test public void testMain() throws Exception { Process process = new ProcessBuilder( ImmutableList.of( Paths.get(System.getProperty("java.home")).resolve("bin/java").toString(), "-cp", System.getProperty("java.class.path"), Main.class.getName())) .redirectError(Redirect.PIPE) .redirectOutput(Redirect.PIPE) .start(); process.waitFor(); String err = new String(ByteStreams.toByteArray(process.getErrorStream()), UTF_8); assertThat(err).contains("Usage: google-java-format"); assertThat(process.exitValue()).isEqualTo(0); }