在使用picocli的实用程序的单元测试中,我想断言 picocli 为选项分配了正确的值。如何在单元测试中获取与选项关联的值?
这是单元测试的当前版本:
@Test
void callWithOptionForSuffix() {
NextMajorSubcommand command = new NextMajorSubcommand();
CommandLine cmdline = new CommandLine(command);
ParseResult parseResult = cmdline.parseArgs("--suffix", "DELTA", "4.5.6");
assertThat(parseResult.hasMatchedPositional(0)).isTrue();
assertThat(parseResult.matchedOptions()).isNotEmpty();
assertThat(parseResult.matchedOption("--suffix").isOption());
}