MCPcopy
hub / github.com/remkop/picocli / testReflection

Method testReflection

src/test/java/picocli/ArgGroupTest.java:433–460  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

431 }
432
433 @Test
434 public void testReflection() {
435 class All {
436 @Option(names = "-x", required = true) int x;
437 @Option(names = "-y", required = true) int y;
438 }
439 class App {
440 @ArgGroup All all;
441 }
442 CommandLine cmd = new CommandLine(new App(), new InnerClassFactory(this));
443 CommandSpec spec = cmd.getCommandSpec();
444 List<ArgGroupSpec> groups = spec.argGroups();
445 assertEquals(1, groups.size());
446
447 ArgGroupSpec group = groups.get(0);
448 assertNotNull(group);
449
450 List<ArgSpec> options = new ArrayList<ArgSpec>(group.args());
451 assertEquals(2, options.size());
452 assertEquals("-x", ((OptionSpec) options.get(0)).shortestName());
453 assertEquals("-y", ((OptionSpec) options.get(1)).shortestName());
454
455 assertNotNull(options.get(0).group());
456 assertSame(group, options.get(0).group());
457
458 assertNotNull(options.get(1).group());
459 assertSame(group, options.get(1).group());
460 }
461
462 @Test
463 public void testReflectionRequiresNonEmpty() {

Callers

nothing calls this directly

Calls 8

getCommandSpecMethod · 0.95
argGroupsMethod · 0.95
argsMethod · 0.95
assertEqualsMethod · 0.80
shortestNameMethod · 0.80
getMethod · 0.65
sizeMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected