Configuring Hooks

Hooks can be configured via Hooks tab and can be configured in the same way as you configure any test case in vREST.

Few important points to note in configuring hooks:

  1. Type of hook
    1. vREST provides 4 types of hooks (Pre and Post Test Run hooks and Pre  and post Test Case hooks).
    2. Data sent to each type of hook is different. For more information on data format, visit this link.
    3. Few Use cases:
      1. Pre Test Run hook can be useful in setting cookie based authentication to third party tools. (Note: Authorization can also be configured via More Options >> Authorizations, similar to test cases.)
      2. Post Test Case hook can be useful in logging bugs in issue tracking systems for failed test cases.
      3. Post Test Run hook can be useful in triggering jobs on the continuous integration server if there are no failed test cases.
  2. Hook Condition
    1. A hook condition can be specified in the "Details" sub-tab of an individual hook.
    2. Few Use Cases:
      1. Suppose you want to execute post test case hook for failed test cases, then provide !{{$tc.result.isPassed}} as condition of the hook.
      2. Suppose you want to execute post test run hook if there are some failed test cases, then provide {{$tr.result.failedCount}} > 0 as condition of the hook.
  3. Viewing hook results
    1. Hook results can be seen in the Test Cases tab.
    2. Test Run hook results are shown where test run statistics are shown in test cases tab as shown in the following snapshot.
       
    3. Test Case hook results are shown in the "Results" sub-tab of individual test cases as shown in the following snapshot.
       

Â