### Question:
OptionGroup implements Serializable { @Override public String toString() { StringBuilder buff = new StringBuilder(); Iterator<Option> iter = getOptions().iterator(); buff.append("["); while (iter.hasNext()) { Option option = iter.next(); if (option.getOpt() != null) { buff.append("-"); buff.append(option.getOpt()); } else { buff.append("--"); buff.append(option.getLongOpt()); } if (option.getDescription() != null) { buff.append(" "); buff.append(option.getDescription()); } if (iter.hasNext()) { buff.append(", "); } } buff.append("]"); return buff.toString(); }  OptionGroup addOption(Option option); Collection<String> getNames(); Collection<Option> getOptions(); void setSelected(Option option); String getSelected(); void setRequired(boolean required); boolean isRequired(); @Override String toString();  }### Answer:
@Test public void testToString() { OptionGroup group1 = new OptionGroup(); group1.addOption(new Option(null, "foo", false, "Foo")); group1.addOption(new Option(null, "bar", false, "Bar")); if (!"[--bar Bar, --foo Foo]".equals(group1.toString())) { assertEquals("[--foo Foo, --bar Bar]", group1.toString()); } OptionGroup group2 = new OptionGroup(); group2.addOption(new Option("f", "foo", false, "Foo")); group2.addOption(new Option("b", "bar", false, "Bar")); if (!"[-b Bar, -f Foo]".equals(group2.toString())) { assertEquals("[-f Foo, -b Bar]", group2.toString()); } }