Skip to content

Commit

Permalink
[#2228] add test
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Apr 11, 2024
1 parent 1dd8632 commit ed43e9a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/test/java/picocli/Issue2228.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package picocli;

import org.junit.Test;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParseResult;

import static org.junit.Assert.*;

public class Issue2228 {

@Command
static class TestCommand implements Runnable {

@Option(names = "-x")
public boolean x;

public void run() {
throw new IllegalStateException("failing, just for fun");
}
}

@Test
public void testParseResult() {
final CommandLine commandLine = new CommandLine(new Issue2228.TestCommand());
final ParseResult[] caughtParseResult = new ParseResult[1];
commandLine.setExecutionExceptionHandler(new CommandLine.IExecutionExceptionHandler() {
public int handleExecutionException(Exception ex, CommandLine exCmdLine, ParseResult parseResult) throws Exception {
assertSame(commandLine, exCmdLine);
assertNotNull(parseResult);
caughtParseResult[0] = parseResult;
return 0;
}
});
assertSame(commandLine.getParseResult(), caughtParseResult[0]);
}
}

0 comments on commit ed43e9a

Please sign in to comment.