use of org.junit.runner.Result in project randomizedtesting by randomizedtesting.
the class RandomizedRunner method runSuite.
/**
* Test execution logic for the entire suite, executing under designated
* {@link RunnerThreadGroup}.
*/
private void runSuite(final RandomizedContext context, final RunNotifier notifier) {
final Result result = new Result();
final RunListener accounting = result.createListener();
notifier.addListener(accounting);
final Randomness classRandomness = runnerRandomness.clone(Thread.currentThread());
context.push(classRandomness);
try {
// Check for automatically hookable listeners.
subscribeListeners(notifier);
// Fire a synthetic "suite started" event.
for (RunListener r : autoListeners) {
try {
r.testRunStarted(suiteDescription);
} catch (Throwable e) {
logger.log(Level.SEVERE, "Panic: RunListener hook shouldn't throw exceptions.", e);
}
}
// Filter out test candidates to see if there's anything left.
// If not, don't bother running class hooks.
final List<TestCandidate> tests = getFilteredTestCandidates(notifier);
if (!tests.isEmpty()) {
Map<TestCandidate, Boolean> ignored = determineIgnoredTests(tests);
if (ignored.size() == tests.size()) {
// All tests ignored, ignore class hooks but report all the ignored tests.
for (TestCandidate c : tests) {
if (ignored.get(c)) {
reportAsIgnored(notifier, groupEvaluator, c);
}
}
} else {
ThreadLeakControl threadLeakControl = new ThreadLeakControl(notifier, this);
Statement s = runTestsStatement(threadLeakControl.notifier(), tests, ignored, threadLeakControl);
s = withClassBefores(s);
s = withClassAfters(s);
s = withClassRules(s);
s = withCloseContextResources(s, LifecycleScope.SUITE);
s = threadLeakControl.forSuite(s, suiteDescription);
try {
s.evaluate();
} catch (Throwable t) {
t = augmentStackTrace(t, runnerRandomness);
if (t instanceof AssumptionViolatedException) {
// Fire assumption failure before method ignores. (GH-103).
notifier.fireTestAssumptionFailed(new Failure(suiteDescription, t));
// see Rants#RANT_3
for (final TestCandidate c : tests) {
notifier.fireTestIgnored(c.description);
}
} else {
fireTestFailure(notifier, suiteDescription, t);
}
}
}
}
} catch (Throwable t) {
notifier.fireTestFailure(new Failure(suiteDescription, t));
}
// Fire a synthetic "suite ended" event and unsubscribe listeners.
for (RunListener r : autoListeners) {
try {
r.testRunFinished(result);
} catch (Throwable e) {
logger.log(Level.SEVERE, "Panic: RunListener hook shouldn't throw exceptions.", e);
}
}
// Final cleanup.
notifier.removeListener(accounting);
unsubscribeListeners(notifier);
context.popAndDestroy();
}
use of org.junit.runner.Result in project randomizedtesting by randomizedtesting.
the class TestCustomMethodProvider method testJUnit4Valid.
@Test
public void testJUnit4Valid() throws InitializationError {
Class<?>[] valid = { T1.class, RT1.class };
for (Class<?> cl : valid) {
Result r = new JUnitCore().run(new RandomizedRunner(cl));
Assert.assertEquals(0, r.getFailureCount());
Assert.assertEquals(1, r.getRunCount());
}
}
use of org.junit.runner.Result in project randomizedtesting by randomizedtesting.
the class TestJUnit3MethodProvider method testJUnit3Overrides.
@Test
public void testJUnit3Overrides() throws Exception {
Result r = new JUnitCore().run(new RandomizedRunner(S3.class));
Assert.assertEquals(0, r.getFailureCount());
Assert.assertEquals(1, r.getRunCount());
}
use of org.junit.runner.Result in project spring-boot by spring-projects.
the class Mockito110Tests method runTests.
private void runTests(Class<?> testClass) {
Result result = new JUnitCore().run(testClass);
for (Failure failure : result.getFailures()) {
System.err.println(failure.getTrace());
}
assertThat(result.getFailureCount()).isEqualTo(0);
assertThat(result.getRunCount()).isGreaterThan(0);
}
use of org.junit.runner.Result in project spring-boot by spring-projects.
the class Mockito21Tests method runTests.
private void runTests(Class<?> testClass) {
Result result = new JUnitCore().run(testClass);
for (Failure failure : result.getFailures()) {
System.err.println(failure.getTrace());
}
assertThat(result.getFailureCount()).isEqualTo(0);
assertThat(result.getRunCount()).isGreaterThan(0);
}
Aggregations