...
The use of reusable functions allows for test features with less code duplication and improved readability.
Ignore the output by prepending the reusable function call with
def v = call ...
...
title | Reusable functions: thunderjet/cross-modules/features/cancel-invoice-with-encumbrance.feature |
---|
...
Nearly all function calls must be prepended with
def v = call ...
, particularly if the output of the function is not required in further assertion or data preparation. In some cases, such as global variable initialization, user/admin login and others, the output must not be ignored, hencedef v = call ...
prefix should not be used.
Expand | ||
---|---|---|
| ||
|
...
When asserting a response that has a possibility of delay, add a
retry
rather than "pausing" the test executionUtilize the
contains
assertion to check if a collection contains specific elements or values.Combine assertions with the
match
keyword to perform deep equality checks on collections and allow flexibility for objects when additional properties are added.Code Block // Bad, if one more property is added to the progress object by the system under test, // the assertion will fail And match response.jobExecutions[0].progress == {exported:1, failed:{duplicatedSrs:0,otherFailed:0}, total:1} // Good And match response.jobExecutions[0].progress contains {exported:1, failed:0, duplicatedSrs:0, total:1}
Use the
contains any
orcontains only
and other assertions like these to check for the presence or absence of specific elements in a collection. Never assume that the order of objects in a collection is going to be guaranteed.Code Block // Bad And match $.requests[0].item.callNumberComponents.callNumber == callNumber1 And match $.requests[1].item.callNumberComponents.callNumber == callNumber2 // Good And match response.requests[*].item.callNumberComponents.callNumber contains callNumber1 And match response.requests[*].item.callNumberComponents.callNumber contains callNumber2
...