public static List<ExecutionEvent> execute( TestEngine testEngine, TestPlanSpecification testPlanSpecification) { TestDescriptor engineTestDescriptor = testEngine.discoverTests(testPlanSpecification); ExecutionEventRecorder listener = new ExecutionEventRecorder(); testEngine.execute(new ExecutionRequest(engineTestDescriptor, listener)); return listener.getExecutionEvents(); }
@Test public void instancePostProcessorInTopLevelClass() { TestDiscoveryRequest request = request().select(forClass(OuterTestCase.class)).build(); ExecutionEventRecorder eventRecorder = executeTests(request); assertEquals(2L, eventRecorder.getTestStartedCount(), "# tests started"); assertEquals(2L, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"); // @formatter:off assertEquals( asList( // NestedTestCase "fooPostProcessTestInstance", "barPostProcessTestInstance", "beforeMethod", "beforeInnerMethod", "testInner", // OuterTestCase "fooPostProcessTestInstance", "beforeMethod", "testOuter"), callSequence, "wrong call sequence"); // @formatter:on }
public static List<ExecutionEvent> execute( TestEngine testEngine, EngineDiscoveryRequest discoveryRequest) { TestDescriptor engineTestDescriptor = testEngine.discover(discoveryRequest); ExecutionEventRecorder listener = new ExecutionEventRecorder(); testEngine.execute(new ExecutionRequest(engineTestDescriptor, listener)); return listener.getExecutionEvents(); }