Skip to content

Commit

Permalink
test for multi-level category application
Browse files Browse the repository at this point in the history
  • Loading branch information
David Saff committed Jan 21, 2010
1 parent 9de3abe commit 86abf33
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java
Expand Up @@ -63,9 +63,8 @@ public BlockJUnit4ClassRunner(Class<?> klass) throws InitializationError {
// Implementation of ParentRunner
//

// TODO: public?
@Override
public void runChild(FrameworkMethod method, RunNotifier notifier) {
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
EachTestNotifier eachNotifier= makeNotifier(method, notifier);
if (method.getAnnotation(Ignore.class) != null) {
runIgnored(eachNotifier);
Expand Down Expand Up @@ -251,8 +250,7 @@ protected String testName(FrameworkMethod method) {
* This can be overridden in subclasses, either by overriding this method,
* or the implementations creating each sub-statement.
*/
// TODO: public?
public Statement methodBlock(FrameworkMethod method) {
protected Statement methodBlock(FrameworkMethod method) {
Object test;
try {
test= new ReflectiveCallable() {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/junit/runners/Suite.java
Expand Up @@ -54,8 +54,7 @@ private static Class<?>[] getAnnotatedClasses(Class<?> klass) throws Initializat
return annotation.value();
}

// TODO: put back!
public final List<Runner> fRunners;
private final List<Runner> fRunners;

/**
* Called reflectively on classes annotated with <code>@RunWith(Suite.class)</code>
Expand Down
Expand Up @@ -6,6 +6,7 @@
import static org.junit.Assert.fail;
import static org.junit.experimental.results.PrintableResult.testResult;
import static org.junit.experimental.results.ResultMatchers.isSuccessful;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Categories;
import org.junit.experimental.categories.Category;
Expand Down Expand Up @@ -278,4 +279,27 @@ public static class RunClassAsCategory {
public void classesCanBeCategories() {
assertThat(testResult(RunClassAsCategory.class), isSuccessful());
}

public static class LeafClass {
@Test public void a() {}
}

@RunWith(Suite.class)
@Category(String.class)
@SuiteClasses({LeafClass.class})
public static class CategorizedSuite {
}

@RunWith(Categories.class)
@IncludeCategory(String.class)
@SuiteClasses({CategorizedSuite.class})
public static class ParentSuite {
}

// TODO: fix fix fix!
@Ignore @Test public void categoriesOnSuiteTrickleDown() {
Result result= new JUnitCore().run(ParentSuite.class);
assertEquals(1, result.getRunCount());
assertEquals(0, result.getFailureCount());
}
}
Expand Up @@ -202,7 +202,6 @@ public void filterSingleMethodFromOldTestClass() throws Exception {
assertEquals(1, child.testCount());
}

// TODO: this test takes too dang long to run
@Test
public void testCountsStandUpToFiltration() {
assertFilterLeavesTestUnscathed(AllTests.class);
Expand Down

0 comments on commit 86abf33

Please sign in to comment.