Esempio n. 1
0
  @Test
  public void hooks_order_across_many_backends() throws Throwable {
    List<HookDefinition> backend1Hooks = mockHooks(3, Integer.MAX_VALUE, 1);
    for (HookDefinition hook : backend1Hooks) {
      glue.addBeforeHook(hook);
    }
    List<HookDefinition> backend2Hooks = mockHooks(2, Integer.MAX_VALUE, 4);
    for (HookDefinition hook : backend2Hooks) {
      glue.addBeforeHook(hook);
    }

    runtime.runBeforeHooks(mock(Reporter.class), new HashSet<Tag>());

    List<HookDefinition> allHooks = new ArrayList<HookDefinition>();
    allHooks.addAll(backend1Hooks);
    allHooks.addAll(backend2Hooks);

    InOrder inOrder = inOrder(allHooks.toArray());
    inOrder.verify(backend1Hooks.get(2)).execute(Matchers.<Scenario>any());
    inOrder.verify(backend2Hooks.get(0)).execute(Matchers.<Scenario>any());
    inOrder.verify(backend1Hooks.get(0)).execute(Matchers.<Scenario>any());
    inOrder.verify(backend2Hooks.get(2)).execute(Matchers.<Scenario>any());
    verify(backend2Hooks.get(1)).execute(Matchers.<Scenario>any());
    verify(backend1Hooks.get(1)).execute(Matchers.<Scenario>any());
  }
Esempio n. 2
0
  @Test
  public void before_hooks_execute_in_order() throws Throwable {
    List<HookDefinition> hooks = mockHooks(3, Integer.MAX_VALUE, 1);
    for (HookDefinition hook : hooks) {
      glue.addBeforeHook(hook);
    }

    runtime.runBeforeHooks(mock(Reporter.class), new HashSet<Tag>());

    InOrder inOrder = inOrder(hooks.toArray());
    inOrder.verify(hooks.get(2)).execute(Matchers.<Scenario>any());
    inOrder.verify(hooks.get(0)).execute(Matchers.<Scenario>any());
    inOrder.verify(hooks.get(1)).execute(Matchers.<Scenario>any());
  }