Link Step

Link steps let test scenarios traverse between resource representations in order to analyse those linked resources.

It is up to the runner implementation to decide whether the link step should only apply to links found in bodies (such as HAL's _links or HTML's anchor element (<a>) or also link headers.

Alternatively HTTP link headers can also be handled with Expect Header statement.

Syntax

  • Link steps are valid where representation is the context.
  • Link steps are valid on top level.

Usage

Link block can be placed at the top of a test scenario document. This way it such a link will be followed from any resource where it is found.

With Link "author" {
    Expect Property "name"
}

Links can be used anywhere that resource representation is the block context. For example, in Class block or Property block.

With Class "Article" {
    With Link "author" {
        Expect Property "name"
    }
}

Strict check

The example above can be modified to require that the presence of the author link.

With Class "Article" {

    // Report a failure when link is missing
    Expect Link "author" {
        Expect Property "name"
    }
}

Usage without children

A strict Expect Link can also be a statement, thus only checking that the link exists, without performing any specific child checks.

With Class "Article" {
    // Follow the link and run top-level steps
    Expect Link "author"
}

With Class "Person" {
    // checks to run against the hypothetical representation
    // behind the "author" link
}

The link should be dereferenced regardless and any applicable top-level steps will be performed.

Last Updated: 7/13/2019, 6:36:07 PM