@Test public void ensureEditingContextInitializationIsTriggeredBeforeTestExecution() throws Throwable { AbstractEditingContextRule editingContext = spy(createEditingContext(TEST_MODEL_NAME)); InOrder inOrder = inOrder(editingContext, mockStatement); editingContext.apply(mockStatement, null, mockTarget).evaluate(); inOrder.verify(editingContext).before(mockTarget); inOrder.verify(mockStatement).evaluate(); }
@Test public void ensureEditingContextCleanUpIsTriggeredEvenIfTestExecutionThrowsException() throws Throwable { AbstractEditingContextRule editingContext = spy(createEditingContext(TEST_MODEL_NAME)); doThrow(new Throwable("test error")).when(mockStatement).evaluate(); InOrder inOrder = inOrder(editingContext, mockStatement); try { editingContext.apply(mockStatement, null, mockTarget).evaluate(); } catch (Throwable exception) { // DO NOTHING } finally { inOrder.verify(mockStatement).evaluate(); inOrder.verify(editingContext).after(mockTarget); } }