JpaUnitFixture extends FixtureInstance { @Override public void beforeSpecification() { try { executor.processBeforeAll(invocation); } catch (final Exception e) { throw new JpaUnitException(e); } super.beforeSpecification(); } JpaUnitFixture(final DecoratorExecutor executor, final Object fixtureObject); @Override void beforeSpecification(); @Override void afterSpecification(); @Override String getSpecificationDescription();  }
@Test public void testBeforeSpecificationCallsProcessAfterAllOnExecutorWithOriginalClassAndCorrespondingExecutor() throws Exception { fixture.beforeSpecification(); final ArgumentCaptor<TestInvocation> invocationCaptor = ArgumentCaptor.forClass(TestInvocation.class); verify(executor).processBeforeAll(invocationCaptor.capture()); final TestInvocation invocation = invocationCaptor.getValue(); assertThat(invocation.getTestClass(), equalTo(TestClass.class)); assertThat(invocation.getContext(), equalTo(ctx)); assertThat(invocation.getFeatureResolver(), notNullValue()); }
@Test public void testBeforeSpecificationThrowsJpaUnitExceptionIfAnyExceptionIsThrown() throws Exception { final Exception exception = new Exception("error"); doThrow(exception).when(executor).processBeforeAll(any(TestInvocation.class)); try { fixture.beforeSpecification(); fail("JpaUnitException is expected"); } catch (final JpaUnitException e) { assertThat(e.getCause(), equalTo(exception)); } }