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:
- Type of hook
- vREST provides 4 types of hooks (Pre and Post Test Run hooks and Pre and post Test Case hooks).
- Data sent to each type of hook is different. For more information on data format, visit this link.
- Few Use cases:
- 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.)
- Post Test Case hook can be useful in logging bugs in issue tracking systems for failed test cases.
- Post Test Run hook can be useful in triggering jobs on the continuous integration server if there are no failed test cases.
- Hook Condition
- A hook condition can be specified in the "Details" sub-tab of an individual hook.
- Few Use Cases:
- Suppose you want to execute post test case hook for failed test cases, then provide !{{$tc.result.isPassed}} as condition of the hook.
- 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.
- Viewing hook results
- Hook results can be seen in the Test Cases tab.
- Test Run hook results are shown where test run statistics are shown in test cases tab as shown in the following snapshot.
- Test Case hook results are shown in the "Results" sub-tab of individual test cases as shown in the following snapshot.