$ cnpm install restwalker
HATEOAS Integration Testing
Restwalker is a tool for integration testing RESTFUL services with HATEOAS hyperlinking. It uses a DSL to describe the traversal of services via rel names.
The service walker accepts a series of commands, which may be strings, functions, or arrays, and interacts with a RESTful services using the commands.
walker.invoke(commmands, context)
context
as the this
context.<path> <commands>
The path describes a rel-based route to a specific invocation on a resource.
<pathitem>.<pathitem>.<pathitem>...
A path must start with the name of a proprety name (resolved on the context object), or root
, which represents the service root. Path items are delimited by .
.
<rel><qualifier>
Each path item contains a rel-name to follow and any qualifiers to apply to the invocation. The following qualifiers are recognized:
${<query-argument>}
. e.g. root.view_list${itemCount=100}
[index]
e.g. root.view_list[1]
Commmands describe interactions with the result of service invocations.
with <propertyName>
These commands use the value of propertyName
on the context object to invoke an endpoint that accepts a payload. e.g. root.create_listing with listingData
as <propertyName
These commands populate the value of propertyName
on the context object as the result of the service invocation. e.g. root.view_profile as profile
emits <statusCode>
- Performs an assertion that the service emits a status code as the result of an invocation. e.g. root.view_list[0].delete emits 204
var script = [
'root.login with credentials as user'
'user.view_profile as profile'
function() { expect(profile.password).to.be.undefined; }
'user.delete emits 204'
];
var context = { username: 'mr_test', password: 'derp' }
walker.invoke(script, context);
Copyright 2014 - 2017 © taobao.org |