### Question:
ProcessLauncherImpl implements ProcessLauncher { @Override public Process launch(String program, List<String> args) throws IOException { List<String> arguments = new ArrayList<>(); arguments.add(program); arguments.addAll(args); ProcessBuilder processBuilder = new ProcessBuilder() .command(arguments) .redirectErrorStream(true) .redirectOutput(Redirect.PIPE); return processBuilder.start(); }  @Override Process launch(String program, List<String> args); @Override boolean isExecutable(String binaryPath);  }### Answer:
@Test public void testLaunch() throws Exception { List<String> args = new ArrayList<>(); args.add("arg1"); args.add("arg2"); ProcessBuilder processBuilder = PowerMock.createMock(ProcessBuilder.class); PowerMock.expectNew(ProcessBuilder.class, new Class[] {}).andReturn(processBuilder); Capture<List<String>> captureCommands = Capture.newInstance(); expect(processBuilder.command(capture(captureCommands))).andReturn(processBuilder); expect(processBuilder.redirectErrorStream(true)).andReturn(processBuilder); expect(processBuilder.redirectOutput(Redirect.PIPE)).andReturn(processBuilder); Process process = mock(Process.class); expect(processBuilder.start()).andReturn(process); PowerMock.replayAll(ProcessBuilder.class, processBuilder); assertEquals(process, processLauncher.launch("program-name", args)); PowerMock.verify(ProcessBuilder.class, processBuilder); List<String> commands = captureCommands.getValue(); assertEquals(3, commands.size()); assertEquals("program-name", commands.get(0)); assertEquals("arg1", commands.get(1)); assertEquals("arg2", commands.get(2)); }