/** * Delegates to the configured {@link TestContextManager} to call * {@linkplain TestContextManager#beforeTestClass() 'before test class'} callbacks. * @throws Exception if a registered TestExecutionListener throws an exception */ @BeforeClass(alwaysRun = true) protected void springTestContextBeforeTestClass() throws Exception { this.testContextManager.beforeTestClass(); }
/** * Delegates to {@link TestContextManager#beforeTestClass}. */ @Override public void beforeAll(ExtensionContext context) throws Exception { getTestContextManager(context).beforeTestClass(); }
/** * Invoke {@link TestContextManager#beforeTestClass()} and then evaluate * the next {@link Statement} in the execution chain (typically an instance * of {@link org.junit.internal.runners.statements.RunBefores RunBefores}). */ @Override public void evaluate() throws Throwable { this.testContextManager.beforeTestClass(); this.next.evaluate(); }
@Test public void invokeTestContextManagerFromConcurrentThreads() { TestContextManager tcm = new TestContextManager(TestCase.class); // Run the actual test several times in order to increase the chance of threads // stepping on each others' toes by overwriting the same mutable state in the // TestContext. IntStream.range(1, 20).forEach(i -> { actualMethods.clear(); // Execute TestExecutionListener in parallel, thereby simulating parallel // test method execution. stream(TestCase.class.getDeclaredMethods()).parallel().forEach(testMethod -> { try { tcm.beforeTestClass(); tcm.beforeTestMethod(testInstance, testMethod); // no need to invoke the actual test method tcm.afterTestMethod(testInstance, testMethod, null); tcm.afterTestClass(); } catch (Exception ex) { throw new RuntimeException(ex); } }); assertThat(actualMethods, equalTo(expectedMethods)); }); assertEquals(0, tcm.getTestContext().attributeNames().length); }
/** * Delegates to the configured {@link TestContextManager} to call * {@link TestContextManager#beforeTestClass() 'before test class'} * callbacks. * * @throws Exception if a registered TestExecutionListener throws an * exception */ @BeforeClass(alwaysRun = true) protected void springTestContextBeforeTestClass() throws Exception { this.testContextManager.beforeTestClass(); }
/** * Delegates to the configured {@link TestContextManager} to call * {@linkplain TestContextManager#beforeTestClass() 'before test class'} callbacks. * @throws Exception if a registered TestExecutionListener throws an exception */ @BeforeClass(alwaysRun = true) protected void springTestContextBeforeTestClass() throws Exception { this.testContextManager.beforeTestClass(); }
/** * Delegates to {@link TestContextManager#beforeTestClass}. */ @Override public void beforeAll(ExtensionContext context) throws Exception { getTestContextManager(context).beforeTestClass(); }
/** * Invoke {@link TestContextManager#beforeTestClass()} and then evaluate * the next {@link Statement} in the execution chain (typically an instance * of {@link org.junit.internal.runners.statements.RunBefores RunBefores}). */ @Override public void evaluate() throws Throwable { this.testContextManager.beforeTestClass(); this.next.evaluate(); }
/** * Delegates to {@link TestContextManager#beforeTestClass}. */ @Override public void beforeAll(ExtensionContext context) throws Exception { getTestContextManager(context).beforeTestClass(); }
/** * Invoke {@link TestContextManager#beforeTestClass()} and then evaluate * the next {@link Statement} in the execution chain (typically an instance * of {@link org.junit.internal.runners.statements.RunBefores RunBefores}). */ @Override public void evaluate() throws Throwable { this.testContextManager.beforeTestClass(); this.next.evaluate(); }
/** * Delegates to {@link TestContextManager#beforeTestClass}. */ @Override public void beforeAll(ExtensionContext context) throws Exception { getTestContextManager(context).beforeTestClass(); }