From 6f855a95479f5180d263e7337cc541e839475b77 Mon Sep 17 00:00:00 2001 From: Remko Popma Date: Tue, 19 Jul 2022 17:51:06 +0900 Subject: [PATCH] [#1471] separate tests for static and dynamic hierarchy --- src/test/java/picocli/Issue1471.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/java/picocli/Issue1471.java b/src/test/java/picocli/Issue1471.java index 9629ea6b5..47134cbe6 100644 --- a/src/test/java/picocli/Issue1471.java +++ b/src/test/java/picocli/Issue1471.java @@ -18,6 +18,11 @@ public CommandLine getTestCommandLine(ParentTestCommand parentCommand, TestComma static class ParentTestCommand { } + @Command(name = "parentTestCommand", mixinStandardHelpOptions = true, scope = INHERIT, + subcommands = TestCommand.class) + static class ParentTestCommand2 { + } + @Command(name = "sorteotest") static class TestCommand { @Command(name = "entertest", description = "Start participating in a giveaway") @@ -29,9 +34,14 @@ void enter(@Parameters(arity = "1") String sentenceType, @Ignore @Test - public void testIssue1741() { + public void testIssue1741_subcommandAddedProgrammatically() { CommandLine commandLine = getTestCommandLine(new ParentTestCommand(), new TestCommand(), CommandLine.defaultFactory()); assertEquals(0, commandLine.execute("sorteotest", "entertest", "sequenceType", "url")); } + @Test + public void testIssue1741_staticHierarchy() { + CommandLine commandLine = new CommandLine(new ParentTestCommand2()); + assertEquals(0, commandLine.execute("sorteotest", "entertest", "sequenceType", "url")); + } }