Constrained blocks

Some blocks can be executed conditionally based on constraining the response or representation.

Currently it is possible to constrain Class, Link and Property blocks by setting conditions on HTTP Status code or property values.

A generic syntax is

'When' ('Property' | 'Status') Not? Operator Value 

Possible operators are:

  1. Strict equality
  2. Inequality
  3. Regular expression
  4. Custom code (to be parsed by test runner)

Possible values are string, numeric and boolean.

Multiple When statements should be joined with a logical AND operator by the runner, ie. a block should be executed only when all conditions are satisfied.


Only execute Class when property matches

With Class "Person" {
    When Property "maritalStatus" Not Equals "Single"

    Expect Link "spouse"
With Class "Book" {
    With Link "author" {
        When Status => ```
            status => status >= 400 && status != 404

        Expect Header Content-Type "application/problem+json"
Last Updated: 8/20/2019, 10:27:57 AM