LUCENE-5238: Fix junitcompat tests (so that they're not triggered when previous errors occur).

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1525815 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dawid Weiss 2013-09-24 08:28:00 +00:00
parent 46729e8622
commit 7df32026ec
3 changed files with 21 additions and 2 deletions

View File

@ -24,6 +24,8 @@ import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import com.carrotsearch.randomizedtesting.RandomizedTest;
public class TestFailIfDirectoryNotClosed extends WithNestedTests {
public TestFailIfDirectoryNotClosed() {
super(true);
@ -39,6 +41,9 @@ public class TestFailIfDirectoryNotClosed extends WithNestedTests {
@Test
public void testFailIfDirectoryNotClosed() {
Result r = JUnitCore.runClasses(Nested1.class);
RandomizedTest.assumeTrue("Ignoring nested test, very likely zombie threads present.",
r.getIgnoreCount() == 0);
for (Failure f : r.getFailures()) {
System.out.println("Failure: " + f);
}

View File

@ -29,6 +29,9 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import com.carrotsearch.randomizedtesting.RandomizedTest;
// LUCENE-4456: Test that we fail if there are unreferenced files
public class TestFailIfUnreferencedFiles extends WithNestedTests {
@ -53,6 +56,17 @@ public class TestFailIfUnreferencedFiles extends WithNestedTests {
@Test
public void testFailIfUnreferencedFiles() {
Result r = JUnitCore.runClasses(Nested1.class);
Assert.assertEquals(1, r.getFailureCount());
RandomizedTest.assumeTrue("Ignoring nested test, very likely zombie threads present.",
r.getIgnoreCount() == 0);
// We are suppressing output anyway so dump the failures.
for (Failure f : r.getFailures()) {
System.out.println(f.getTrace());
}
Assert.assertEquals("Expected exactly one failure.",
1, r.getFailureCount());
Assert.assertTrue("Expected unreferenced files assertion.",
r.getFailures().get(0).getTrace().contains("unreferenced files:"));
}
}

View File

@ -49,7 +49,7 @@ public final class TestRuleIgnoreTestSuites implements TestRule {
@Override
public void evaluate() throws Throwable {
if (NestedTestSuite.class.isAssignableFrom(d.getTestClass())) {
LuceneTestCase.assumeTrue("Nested suite class ignored (started as stand-along).",
LuceneTestCase.assumeTrue("Nested suite class ignored (started as stand-alone).",
isRunningNested());
}
s.evaluate();