Skip to content

Commit

Permalink
Rename ExecutionEventRecordingEngineExecutionListener
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Jan 13, 2016
1 parent 3a0605c commit 4421cef
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 54 deletions.
Expand Up @@ -20,8 +20,7 @@
import org.junit.gen5.commons.util.ToStringBuilder;

/**
* Represents an event collected by
* {@link ExecutionEventRecordingEngineExecutionListener}.
* Represents an event collected by {@link ExecutionEventRecorder}.
*
* @see ExecutionEventConditions
*/
Expand Down
Expand Up @@ -29,11 +29,11 @@
*
* @see ExecutionEvent
*/
public class ExecutionEventRecordingEngineExecutionListener implements EngineExecutionListener {
public class ExecutionEventRecorder implements EngineExecutionListener {

public static List<ExecutionEvent> execute(TestEngine testEngine, TestPlanSpecification testPlanSpecification) {
TestDescriptor engineTestDescriptor = testEngine.discoverTests(testPlanSpecification);
ExecutionEventRecordingEngineExecutionListener listener = new ExecutionEventRecordingEngineExecutionListener();
ExecutionEventRecorder listener = new ExecutionEventRecorder();
testEngine.execute(new ExecutionRequest(engineTestDescriptor, listener));
return listener.getExecutionEvents();
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
import org.junit.AssumptionViolatedException;
import org.junit.gen5.api.Test;
import org.junit.gen5.engine.ExecutionEvent;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.TestPlanSpecification;
import org.junit.gen5.engine.junit4.samples.junit3.PlainJUnit3TestCaseWithSingleTestWhichFails;
import org.junit.gen5.engine.junit4.samples.junit4.EnclosedJUnit4TestCase;
Expand Down Expand Up @@ -366,6 +366,6 @@ void executesJUnit4SuiteWithExceptionThrowingRunner() {
private static List<ExecutionEvent> execute(Class<?> testClass) {
JUnit4TestEngine engine = new JUnit4TestEngine();
TestPlanSpecification testPlanSpecification = build(forClass(testClass));
return ExecutionEventRecordingEngineExecutionListener.execute(engine, testPlanSpecification);
return ExecutionEventRecorder.execute(engine, testPlanSpecification);
}
}
Expand Up @@ -14,7 +14,7 @@

import org.junit.gen5.api.BeforeEach;
import org.junit.gen5.engine.EngineDescriptor;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.ExecutionRequest;
import org.junit.gen5.engine.TestDescriptor;
import org.junit.gen5.engine.TestPlanSpecification;
Expand All @@ -32,13 +32,13 @@ abstract class AbstractJUnit5TestEngineTests {
void initListeners() {
}

protected ExecutionEventRecordingEngineExecutionListener executeTestsForClass(Class<?> testClass) {
protected ExecutionEventRecorder executeTestsForClass(Class<?> testClass) {
return executeTests(build(forClass(testClass)));
}

protected ExecutionEventRecordingEngineExecutionListener executeTests(TestPlanSpecification spec) {
protected ExecutionEventRecorder executeTests(TestPlanSpecification spec) {
TestDescriptor testDescriptor = discoverTests(spec);
ExecutionEventRecordingEngineExecutionListener eventRecorder = new ExecutionEventRecordingEngineExecutionListener();
ExecutionEventRecorder eventRecorder = new ExecutionEventRecorder();
engine.execute(new ExecutionRequest(testDescriptor, eventRecorder));
return eventRecorder;
}
Expand Down
Expand Up @@ -26,7 +26,7 @@
import org.junit.gen5.api.extension.ExtendWith;
import org.junit.gen5.api.extension.ExtensionRegistrar;
import org.junit.gen5.api.extension.ExtensionRegistry;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.TestPlanSpecification;

/**
Expand All @@ -41,7 +41,7 @@ public class ClassLevelCallbackTests extends AbstractJUnit5TestEngineTests {
public void beforeAllAndAfterAllCallbacks() {
TestPlanSpecification spec = build(forClass(InstancePerMethodTestCase.class));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(spec);
ExecutionEventRecorder eventRecorder = executeTests(spec);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand Down
Expand Up @@ -29,7 +29,7 @@
import org.junit.gen5.api.extension.ExtendWith;
import org.junit.gen5.api.extension.TestExecutionCondition;
import org.junit.gen5.api.extension.TestExtensionContext;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.TestPlanSpecification;

/**
Expand Down Expand Up @@ -57,7 +57,7 @@ public void tearDown() {
@Test
public void executeTestsWithDisabledTestClass() {
TestPlanSpecification spec = build(forClass(DisabledTestClassTestCase.class));
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(spec);
ExecutionEventRecorder eventRecorder = executeTests(spec);

assertEquals(1L, eventRecorder.getContainerSkippedCount(), "# container skipped");
assertEquals(0L, eventRecorder.getTestStartedCount(), "# tests started");
Expand All @@ -66,7 +66,7 @@ public void executeTestsWithDisabledTestClass() {
@Test
public void executeTestsWithDisabledTestMethods() {
TestPlanSpecification spec = build(forClass(DisabledTestMethodsTestCase.class));
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(spec);
ExecutionEventRecorder eventRecorder = executeTests(spec);

assertEquals(2L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(2L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand Down
Expand Up @@ -25,7 +25,7 @@
import org.junit.gen5.api.BeforeAll;
import org.junit.gen5.api.BeforeEach;
import org.junit.gen5.api.Test;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.TestPlanSpecification;
import org.opentest4j.AssertionFailedError;

Expand All @@ -40,7 +40,7 @@ public void failureInTestMethodIsRegistered() throws NoSuchMethodException {
TestPlanSpecification testPlanSpecification = TestPlanSpecification.build(
TestPlanSpecification.forMethod(FailureTestCase.class, method));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestFailedCount(), "# tests failed");
Expand All @@ -56,7 +56,7 @@ public void uncheckedExceptionInTestMethodIsRegistered() throws NoSuchMethodExce
TestPlanSpecification testPlanSpecification = TestPlanSpecification.build(
TestPlanSpecification.forMethod(FailureTestCase.class, method));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestFailedCount(), "# tests failed");
Expand All @@ -72,7 +72,7 @@ public void checkedExceptionInTestMethodIsRegistered() throws NoSuchMethodExcept
TestPlanSpecification testPlanSpecification = TestPlanSpecification.build(
TestPlanSpecification.forMethod(FailureTestCase.class, method));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestFailedCount(), "# tests failed");
Expand All @@ -90,7 +90,7 @@ public void checkedExceptionInBeforeEachIsRegistered() throws NoSuchMethodExcept

FailureTestCase.exceptionToThrowInBeforeEach = Optional.of(new IOException("checked"));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestFailedCount(), "# tests failed");
Expand All @@ -107,7 +107,7 @@ public void checkedExceptionInAfterEachIsRegistered() throws NoSuchMethodExcepti

FailureTestCase.exceptionToThrowInAfterEach = Optional.of(new IOException("checked"));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestFailedCount(), "# tests failed");
Expand All @@ -124,7 +124,7 @@ public void checkedExceptionInAfterEachIsSuppressedByExceptionInTest() throws No

FailureTestCase.exceptionToThrowInAfterEach = Optional.of(new IOException("checked"));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertRecordedExecutionEventsContainsExactly(eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
Expand All @@ -147,7 +147,7 @@ public void checkedExceptionInBeforeAllIsRegistered() throws NoSuchMethodExcepti

FailureTestCase.exceptionToThrowInBeforeAll = Optional.of(new IOException("checked"));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertRecordedExecutionEventsContainsExactly(eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
Expand All @@ -165,7 +165,7 @@ public void checkedExceptionInAfterAllIsRegistered() throws NoSuchMethodExceptio

FailureTestCase.exceptionToThrowInAfterAll = Optional.of(new IOException("checked"));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertRecordedExecutionEventsContainsExactly(eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
Expand Down
Expand Up @@ -23,7 +23,7 @@
import org.junit.gen5.api.extension.ExtendWith;
import org.junit.gen5.api.extension.InstancePostProcessor;
import org.junit.gen5.api.extension.TestExtensionContext;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.TestPlanSpecification;

/**
Expand All @@ -35,7 +35,7 @@ public class InstancePostProcessorTests extends AbstractJUnit5TestEngineTests {
public void instancePostProcessorInTopLevelClass() {
TestPlanSpecification spec = build(forClass(OuterTestCase.class));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(spec);
ExecutionEventRecorder eventRecorder = executeTests(spec);

assertEquals(2L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(2L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand Down
Expand Up @@ -27,7 +27,7 @@
import org.junit.gen5.api.extension.ExtensionRegistrar;
import org.junit.gen5.api.extension.ExtensionRegistry;
import org.junit.gen5.api.extension.TestExtensionContext;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.TestPlanSpecification;

/**
Expand All @@ -42,7 +42,7 @@ public class MethodLevelCallbackTests extends AbstractJUnit5TestEngineTests {
public void beforeEachAndAfterEachCallbacks() {
TestPlanSpecification spec = build(forClass(OuterTestCase.class));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(spec);
ExecutionEventRecorder eventRecorder = executeTests(spec);

assertEquals(2L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(2L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand Down
Expand Up @@ -19,7 +19,7 @@
import org.junit.gen5.api.Nested;
import org.junit.gen5.api.Test;
import org.junit.gen5.engine.EngineDescriptor;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.TestPlanSpecification;

/**
Expand All @@ -39,7 +39,7 @@ public void nestedTestsAreCorrectlyDiscovered() {

@Test
public void nestedTestsAreExecuted() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(TestCaseWithNesting.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(TestCaseWithNesting.class);

assertEquals(3L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(2L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand All @@ -58,8 +58,7 @@ public void doublyNestedTestsAreCorrectlyDiscovered() {

@Test
public void doublyNestedTestsAreExecuted() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(
TestCaseWithDoubleNesting.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(TestCaseWithDoubleNesting.class);

assertEquals(5L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(3L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand Down
Expand Up @@ -21,7 +21,7 @@
import org.junit.gen5.api.TestInfo;
import org.junit.gen5.api.extension.ExtendWith;
import org.junit.gen5.api.extension.MethodParameterResolver;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.junit5.execution.injection.sample.CustomAnnotation;
import org.junit.gen5.engine.junit5.execution.injection.sample.CustomAnnotationParameterResolver;
import org.junit.gen5.engine.junit5.execution.injection.sample.CustomType;
Expand All @@ -37,8 +37,7 @@ public class ParameterResolverTests extends AbstractJUnit5TestEngineTests {

@Test
public void executeTestsForMethodInjectionCases() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(
MethodInjectionTestCase.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(MethodInjectionTestCase.class);

assertEquals(8L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(7L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand All @@ -49,8 +48,7 @@ public void executeTestsForMethodInjectionCases() {

@Test
public void executeTestsForMethodInjectionInBeforeAndAfterEachMethods() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(
BeforeAndAfterMethodInjectionTestCase.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(BeforeAndAfterMethodInjectionTestCase.class);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand All @@ -61,8 +59,7 @@ public void executeTestsForMethodInjectionInBeforeAndAfterEachMethods() {

@Test
public void executeTestsForMethodInjectionInBeforeAndAfterAllMethods() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(
BeforeAndAfterAllMethodInjectionTestCase.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(BeforeAndAfterAllMethodInjectionTestCase.class);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand All @@ -73,8 +70,7 @@ public void executeTestsForMethodInjectionInBeforeAndAfterAllMethods() {

@Test
public void executeTestsForMethodWithExtendWithAnnotation() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(
ExtendWithOnMethodTestCase.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(ExtendWithOnMethodTestCase.class);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand Down
Expand Up @@ -17,7 +17,7 @@
import org.junit.gen5.api.BeforeEach;
import org.junit.gen5.api.Test;
import org.junit.gen5.engine.EngineDescriptor;
import org.junit.gen5.engine.ExecutionEventRecordingEngineExecutionListener;
import org.junit.gen5.engine.ExecutionEventRecorder;
import org.junit.gen5.engine.TestPlanSpecification;
import org.opentest4j.TestAbortedException;

Expand Down Expand Up @@ -58,7 +58,7 @@ public void moreThanOneTestClassIsExecuted() {
TestPlanSpecification.forClass(FirstOfTwoTestCases.class),
TestPlanSpecification.forClass(SecondOfTwoTestCases.class));

ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTests(testPlanSpecification);
ExecutionEventRecorder eventRecorder = executeTests(testPlanSpecification);

assertEquals(6L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(5L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand All @@ -70,7 +70,7 @@ public void moreThanOneTestClassIsExecuted() {

@Test
public void allTestsInClassAreRunWithBeforeEach() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(MyStandardTestCase.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(MyStandardTestCase.class);

assertEquals(4L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(2L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand All @@ -86,7 +86,7 @@ public void allTestsInClassAreRunWithBeforeEach() {

@Test
public void allTestsInClassAreRunWithAfterEach() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(MyStandardTestCase.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(MyStandardTestCase.class);

assertEquals(4L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(4, MyStandardTestCase.countAfter, "# after each calls");
Expand All @@ -97,8 +97,7 @@ public void allTestsInClassAreRunWithAfterEach() {

@Test
public void testsFailWhenBeforeEachFails() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(
TestCaseWithFailingBefore.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(TestCaseWithFailingBefore.class);

assertEquals(2L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(0L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand All @@ -112,8 +111,7 @@ public void testsFailWhenBeforeEachFails() {

@Test
public void testsFailWhenAfterEachFails() {
ExecutionEventRecordingEngineExecutionListener eventRecorder = executeTestsForClass(
TestCaseWithFailingAfter.class);
ExecutionEventRecorder eventRecorder = executeTestsForClass(TestCaseWithFailingAfter.class);

assertEquals(1L, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(0L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
Expand Down

0 comments on commit 4421cef

Please sign in to comment.