* case, to provide a selection of categories to include/exclude.
*/
@Test
public void getFilterCategoriesBeforeRun() {
JUnitCore core = new JUnitCore();
Request req = Request.aClass(ACategoryTest.class);
Runner r = req.getRunner();
Set<Category> cats = new HashSet<Category>();
for (Description each : r.getDescription().getChildren()) {
Category c = CategoryResolver.getCategory(each);
if (c != null) {
cats.add(c);
}
}
// A is twice
assertEquals (3, cats.size());
// select Category "A"
Category a = null;
for (Iterator<Category> iter = cats.iterator() ; iter.hasNext() ; ) {
Category c = (Category) iter.next();
if ("A".equals(c.value())) {
a = c;
}
}
assertNotNull(a);
assertEquals ("A", a.value());
// and now run all tests
Result res = core.run(req.filterWith(new CategoryFilter(a.value())));
assertEquals(2, res.getRunCount());
}