NAME

Plack::App::DAIA::Test::Suite - Test DAIA Servers via a test scripting language

VERSION

version 0.55

SYNOPSIS

use Test::More;
use Plack::App::DAIA::Test::Suite;

provedaia <<SUITE, server => "http://example.com/your-daia-server";
foo:bar

# document expected
{ "document" : [ { } ] }
SUITE

done_testing;

METHODS

provedaia ( $suite [, %options ] )

Run a DAIA test suite from a string or stream (GLOB or IO::File). A DAIA test suite lists servers, identifiers, and DAIA/JSON response fragments to test DAIA servers. The command line client provedaia is included in this distribution for convenience.

Additional option supported so far are server and ids. The former is equivalent to an inital server=... statement in you test suite and the latter is equivalent to an initial list of identifiers in you test suite.

If the option end is set, all lines before __END__ are ignored in the test suite script. The option verbose adds more diagnostic messages.

TEST SUITE FORMAT

A test suite is defined in a text-based format that is parsed line by line. Empty lines are ignored. There are four kinds of statements:

comments

All lines starting with # are treated as comments.

responses

All lines starting with {} begin a response (fragment) in JSON format. Following lines are treated as part of the JSON structure until an empty line or the end of the file. References to assigned variables, such as $server, are replaced, including the special variable $id for the current identifier.

assignements

All lines of the form key=value, where key contains of lowercase letters a-z only, are treated as variable assignements. In particular, the variable server is used to set a server (an URL or a PSGI script) and the variable id can be used to reset the list of identifiers.

identifiers

All other non-empty lines are treated as identifiers. Identifiers are not expected to be URI-encoded.

Every time a response has been read, all preceding identifiers are used to query the current server and the response is compared with Test::JSON::Entails. Here is an example of a test suite:

server=http://example.com/your-daia-server

# some document ids
isbn:0486225437
urn:isbn:0486225437
http://example.org/this-is-also-an-id

# the response must contain at least one document with the query id
{ "document" : [
  { "id" : "$id" }
] }

See the file app.psgi and examples/daia-ubbielefeld.pl for further examples of test suites included in server implementations.

AUTHOR

Jakob Voß

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Jakob Voß.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.