Skip to content

Commit 94bc75d

Browse files
committed
[#1768] add test
1 parent cf432ed commit 94bc75d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/picocli/ArgGroupTest.java

+26
Original file line numberDiff line numberDiff line change
@@ -4351,4 +4351,30 @@ public void testIssue1680MultiplicityZeroCausesInfiniteLoop() {
43514351
}
43524352
}
43534353

4354+
@Test
4355+
public void testReuseBothCommandLineAndUserObjectWithArgGroup() {
4356+
MyCommand userObject = new MyCommand();
4357+
CommandLine cmdLine = new CommandLine(userObject);
4358+
cmdLine.execute("--group", "group", "--option", "option");
4359+
cmdLine.execute();
4360+
assertNull("Expected option to be reset to null", userObject.option);
4361+
assertNull("Expected group option to be reset to null", userObject.group.option);
4362+
}
4363+
4364+
@Command(name = "command")
4365+
static class MyCommand implements Runnable {
4366+
@Option(names = "--option"/*, defaultValue = Option.NULL_VALUE*/)
4367+
private String option;
4368+
4369+
@ArgGroup
4370+
private Group group = new Group();
4371+
4372+
private static class Group {
4373+
@Option(names = "--group", defaultValue = Option.NULL_VALUE)
4374+
private String option;
4375+
}
4376+
4377+
public void run() {
4378+
}
4379+
}
43544380
}

0 commit comments

Comments
 (0)