Skip to content

Commit

Permalink
#40: Failure on Runner level work for arbitrary nesting depths
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
On behalf of the community, the JUnit Lambda Team thanks
msg systems ag (http://www.msg-systems.com) for supporting
the JUnit crowdfunding campaign!
------------------------------------------------------------------------
  • Loading branch information
marcphilipp committed Jan 6, 2016
1 parent 0f7dde4 commit 0dbb0c2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
Expand Up @@ -22,6 +22,7 @@
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionRequest;
import org.junit.gen5.engine.junit4.samples.EnclosedJUnit4TestCase;
import org.junit.gen5.engine.junit4.samples.JUnit4SuiteOfSuiteWithJUnit4TestCaseWithErrorInBeforeClass;
import org.junit.gen5.engine.junit4.samples.JUnit4SuiteWithJUnit3SuiteWithSingleTestCase;
import org.junit.gen5.engine.junit4.samples.JUnit4SuiteWithJUnit4TestCaseWithErrorInBeforeClass;
import org.junit.gen5.engine.junit4.samples.JUnit4TestCaseWithErrorInAfterClass;
Expand Down Expand Up @@ -171,6 +172,25 @@ void executesJUnit4SuiteWithJUnit4TestCaseWithErrorInBeforeClass() {
event(engine(), finishedSuccessfully()));
}

@Test
void executesJUnit4SuiteOfSuiteWithJUnit4TestCaseWithErrorInBeforeClass() {
Class<?> suiteOfSuiteClass = JUnit4SuiteOfSuiteWithJUnit4TestCaseWithErrorInBeforeClass.class;
Class<?> suiteClass = JUnit4SuiteWithJUnit4TestCaseWithErrorInBeforeClass.class;
Class<?> testClass = JUnit4TestCaseWithErrorInBeforeClass.class;

List<ExecutionEvent> executionEvents = execute(suiteOfSuiteClass);

assertRecordedExecutionEventsContainsExactly(executionEvents, //
event(engine(), started()), //
event(container(suiteOfSuiteClass.getName()), started()), //
event(container(suiteClass.getName()), started()), //
event(container(testClass.getName()), started()), //
event(container(testClass.getName()), finishedWithFailure(causeMessage("something went wrong"))), //
event(container(suiteClass.getName()), finishedSuccessfully()), //
event(container(suiteOfSuiteClass.getName()), finishedSuccessfully()), //
event(engine(), finishedSuccessfully()));
}

@Test
void executesJUnit4TestCaseWithErrorInAfterClass() {
Class<?> testClass = JUnit4TestCaseWithErrorInAfterClass.class;
Expand Down
@@ -0,0 +1,20 @@
/*
* Copyright 2015-2016 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.junit.gen5.engine.junit4.samples;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses(JUnit4SuiteWithJUnit4TestCaseWithErrorInBeforeClass.class)
public class JUnit4SuiteOfSuiteWithJUnit4TestCaseWithErrorInBeforeClass {
}
Expand Up @@ -80,14 +80,15 @@ public void testAssumptionFailure(Failure failure) {

@Override
public void testFailure(Failure failure) {
TestDescriptor testDescriptor = lookupDescriptor(failure.getDescription());
Description description = failure.getDescription();
TestDescriptor testDescriptor = lookupDescriptor(description);
executionResults.put(testDescriptor, failed(failure.getException()));
if (testDescriptor.isContainer()) {
if (!startedDescriptors.contains(testDescriptor)) {
fireExecutionStarted(testDescriptor);
testStarted(description);
}
if (!finishedDescriptors.contains(testDescriptor) && !runnerTestDescriptor.equals(testDescriptor)) {
fireExecutionFinished(testDescriptor);
testFinished(description);
}
}
}
Expand Down

0 comments on commit 0dbb0c2

Please sign in to comment.