anchor.diff:  
   
   %% @private
  --spec call_if_defined(undefined | fun((term()) -> ok), term()) -> ok.
  -call_if_defined(undefined, _Input) -> ok;
  -call_if_defined(Fun, Input) -> Fun(Input).
  +-spec call_hook_if_defined(undefined | hook(), term(), test_ctx()) -> ok.
  +call_hook_if_defined(undefined, _Input, _TestCtx) ->
  +    ok;
  +call_hook_if_defined(HookFun, Input, TestCtx) ->
  +    try
  +        HookFun(Input),
  +        ok
  +    catch Type:Error:Stacktrace ->
  +        ct:pal("Unexpected exception when calling test hook: ~p", [
  +            iolist_to_binary(lager:pr_stacktrace(Stacktrace, {Type, Error}))
  +        ]),
  +        fail_test(TestCtx)
  +    end.
   
   
   %% @private
  
positive.code:     Step =:= handle_workflow_interrupted;
      Step =:= handle_workflow_execution_stopped
  ->
      call_if_defined(
          EndedIncarnation#atm_workflow_execution_incarnation_test_spec.after_hook,
          build_mock_call_ctx(StepMockCallReport, TestCtx)
      ),
      TestCtx#test_ctx{ongoing_incarnations = []};
  
  
negative.code: ) ->
      StepMockCallCtx = build_mock_call_ctx(StepMockCallReport, TestCtx0),
  
      call_hook_if_defined(get_hook(StepMockCallReport, StepMockSpec), StepMockCallCtx, TestCtx0),
  
      ExpStateDiff = get_exp_state_diff(StepMockCallReport, StepMockSpec),
      TestCtx1 = case ExpStateDiff(StepMockCallCtx) of
  