}
@Test
@Assumption(methods = "onUnix")
public void shouldCaptureLastLineOfSimpleCommandOnUnix() {
CapturingOverthereExecutionOutputHandler captured = capturingHandler();
int res = connection.execute(multiHandler(sysoutHandler(), captured), syserrHandler(),
CmdLine.build("echo", "-n", "line", "that", "does", "not", "end", "in", "a", "newline"));
assertThat(res, equalTo(0));
if (captured.getOutputLines().size() > 1) {
// When using ssh_interactive_sudo, the output may be proceeded by the password prompt and possibly even the
// sudo warning message.
assertThat(captured.getOutputLines().get(captured.getOutputLines().size() - 2), containsString("assword"));
assertThat(captured.getOutputLines().get(captured.getOutputLines().size() - 1), containsString("line that does not end in a newline"));
} else {
assertThat(captured.getOutputLines().size(), equalTo(1));
assertThat(captured.getOutput(), containsString("line that does not end in a newline"));
}
}