mirror of https://github.com/apache/lucene.git
Correcting the test for the pessimistic random seed.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1376390 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
03473400bb
commit
95b22040ca
|
@ -19,9 +19,9 @@ package org.apache.lucene.util;
|
||||||
|
|
||||||
import org.apache.lucene.util.junitcompat.WithNestedTests;
|
import org.apache.lucene.util.junitcompat.WithNestedTests;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.Description;
|
||||||
import org.junit.runner.JUnitCore;
|
import org.junit.runner.JUnitCore;
|
||||||
import org.junit.runner.Result;
|
import org.junit.runner.Result;
|
||||||
import org.junit.runner.notification.Failure;
|
import org.junit.runner.notification.Failure;
|
||||||
|
@ -45,7 +45,7 @@ public class TestMaxFailuresRule extends WithNestedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Nested extends WithNestedTests.AbstractNestedTest {
|
public static class Nested extends WithNestedTests.AbstractNestedTest {
|
||||||
@Repeat(iterations = 100)
|
@Repeat(iterations = 500)
|
||||||
public void testFailSometimes() {
|
public void testFailSometimes() {
|
||||||
assertFalse(random().nextInt(5) == 0);
|
assertFalse(random().nextInt(5) == 0);
|
||||||
}
|
}
|
||||||
|
@ -61,22 +61,40 @@ public class TestMaxFailuresRule extends WithNestedTests {
|
||||||
LuceneTestCase.ignoreAfterMaxFailures.failuresSoFar = 0;
|
LuceneTestCase.ignoreAfterMaxFailures.failuresSoFar = 0;
|
||||||
|
|
||||||
JUnitCore core = new JUnitCore();
|
JUnitCore core = new JUnitCore();
|
||||||
final int [] assumptions = new int [1];
|
final StringBuilder results = new StringBuilder();
|
||||||
core.addListener(new RunListener() {
|
core.addListener(new RunListener() {
|
||||||
|
char lastTest;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testStarted(Description description) throws Exception {
|
||||||
|
lastTest = 'S'; // success.
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testAssumptionFailure(Failure failure) {
|
public void testAssumptionFailure(Failure failure) {
|
||||||
assumptions[0]++;
|
lastTest = 'A'; // assumption failure.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testFailure(Failure failure) throws Exception {
|
||||||
|
lastTest = 'F'; // failure
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testFinished(Description description) throws Exception {
|
||||||
|
results.append(lastTest);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Result result = core.run(Nested.class);
|
Result result = core.run(Nested.class);
|
||||||
Assert.assertEquals(100, result.getRunCount());
|
Assert.assertEquals(500, result.getRunCount());
|
||||||
Assert.assertEquals(0, result.getIgnoreCount());
|
Assert.assertEquals(0, result.getIgnoreCount());
|
||||||
Assert.assertEquals(2, result.getFailureCount());
|
Assert.assertEquals(2, result.getFailureCount());
|
||||||
|
|
||||||
// JUnit doesn't pass back the number of successful tests, just make sure
|
// Make sure we had exactly two failures followed by assumption-failures
|
||||||
// we did have enough assumption-failures.
|
// resulting from ignored tests.
|
||||||
Assert.assertTrue(assumptions[0] > 50);
|
Assert.assertTrue(results.toString(),
|
||||||
|
results.toString().matches("(S*F){2}A+"));
|
||||||
} finally {
|
} finally {
|
||||||
LuceneTestCase.ignoreAfterMaxFailures.maxFailures = maxFailures;
|
LuceneTestCase.ignoreAfterMaxFailures.maxFailures = maxFailures;
|
||||||
LuceneTestCase.ignoreAfterMaxFailures.failuresSoFar = failuresSoFar;
|
LuceneTestCase.ignoreAfterMaxFailures.failuresSoFar = failuresSoFar;
|
||||||
|
|
Loading…
Reference in New Issue