Skip to content

Commit

Permalink
Merge branch 'issue227' of https://github.com/kcooney/junit into kcoo…
Browse files Browse the repository at this point in the history
…ney-issue227
  • Loading branch information
dsaff committed Jun 14, 2011
2 parents c53f62d + de8dfa6 commit 82a7091
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
14 changes: 11 additions & 3 deletions acknowledgements.txt
Expand Up @@ -71,9 +71,9 @@
Markus Keller: Reported bug (github#163):
Bad comparison failure message when using assertEquals(String, String)

Kevin Cooney (kcooney):
Patches for runLeaf, public multiple failure exception, abstract base
class for TestRule, assertion messages and null.
Kevin Cooney (kcooney@github):
Patches for runLeaf, public multiple failure exception,
assertion messages and null.

2011 Mar 04
Jerome Lacoste (lacostej@github) for initial patch for GH-191.
Expand All @@ -87,10 +87,18 @@
2011 Apr 29
reinholdfuereder@github: bug report, test, and fix for GH-38:
ParentRunner filtering
<<<<<<< HEAD

2011 Apr 29
Markus Keller (mkeller@github): Report for GH-187:
Unintentional dependency on Java 6

2011 Jun 06
Vampire@github: Report for GH-235: 4.7 release notes incorrect.
=======
2011 May 31
Kevin Cooney (kcooney@github): Patches for filtering test suites:
copy List returned by getChildren() before mutating it;
optimize ParentRunner.filter for nested suites;
optimize Filter.intersect for common cases
>>>>>>> de8dfa6dcaf4353c5e399ff976db6803db73f9bd
2 changes: 1 addition & 1 deletion src/main/java/org/junit/runners/ParentRunner.java
Expand Up @@ -353,7 +353,7 @@ private void validate() throws InitializationError {

private List<T> getFilteredChildren() {
if (fFilteredChildren == null)
fFilteredChildren = getChildren();
fFilteredChildren = new ArrayList<T>(getChildren());
return fFilteredChildren;
}

Expand Down
Expand Up @@ -8,7 +8,9 @@
import static org.junit.runner.Description.createSuiteDescription;
import static org.junit.runner.Description.createTestDescription;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
Expand All @@ -22,6 +24,8 @@
import org.junit.runner.manipulation.NoTestsRemainException;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;

public class ParentRunnerFilteringTest {
private static Filter notThisMethodName(final String methodName) {
Expand Down Expand Up @@ -91,6 +95,38 @@ public void testSuiteFiltering() throws Exception {
fail("Expected 'NoTestsRemainException' due to complete filtering");
}

public static class SuiteWithUnmodifyableChildList extends Suite {

public SuiteWithUnmodifyableChildList(
Class<?> klass, RunnerBuilder builder)
throws InitializationError {
super(klass, builder);
}

@Override
protected List<Runner> getChildren() {
return Collections.unmodifiableList(super.getChildren());
}
}

@RunWith(SuiteWithUnmodifyableChildList.class)
@SuiteClasses({ ExampleTest.class })
public static class ExampleSuiteWithUnmodifyableChildList {
}

@Test
public void testSuiteFilteringWithUnmodifyableChildList() throws Exception {
Runner runner= Request.aClass(ExampleSuiteWithUnmodifyableChildList.class)
.getRunner();
Filter filter= notThisMethodName("test1");
try {
filter.apply(runner);
} catch (NoTestsRemainException e) {
return;
}
fail("Expected 'NoTestsRemainException' due to complete filtering");
}

@Test
public void testRunSuiteFiltering() throws Exception {
Request request= Request.aClass(ExampleSuite.class);
Expand Down

0 comments on commit 82a7091

Please sign in to comment.