@Test void dynamicTestsAreExecutedFromStream() { LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicStream")).build(); ExecutionEventRecorder eventRecorder = executeTests(request); assertRecordedExecutionEventsContainsExactly( eventRecorder.getExecutionEvents(), // event(engine(), started()), // event(container(MyDynamicTestCase.class), started()), // event(container("dynamicStream"), started()), // event(dynamicTestRegistered("dynamic-test:#1")), // event(test("dynamic-test:#1", "succeedingTest"), started()), // event(test("dynamic-test:#1", "succeedingTest"), finishedSuccessfully()), // event(dynamicTestRegistered("dynamic-test:#2")), // event(test("dynamic-test:#2", "failingTest"), started()), // event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), // event(container("dynamicStream"), finishedSuccessfully()), // event(container(MyDynamicTestCase.class), finishedSuccessfully()), // event(engine(), finishedSuccessfully())); }
@Test void dynamicTestsAreExecutedFromCollection() { LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicCollection")).build(); ExecutionEventRecorder eventRecorder = executeTests(request); assertAll( // () -> assertEquals(3, eventRecorder.getContainerStartedCount(), "# container started"), () -> assertEquals(2, eventRecorder.getDynamicTestRegisteredCount(), "# dynamic registered"), () -> assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed"), () -> assertEquals(3, eventRecorder.getContainerFinishedCount(), "# container finished")); }
private static List<ExecutionEvent> execute(Class<?> testClass) { VintageTestEngine engine = new VintageTestEngine(); LauncherDiscoveryRequest discoveryRequest = request().selectors(selectClass(testClass)).build(); return ExecutionEventRecorder.execute(engine, discoveryRequest); }