Plack::App::DAIA::Test::Suite - Test DAIA Servers via a test scripting language
version 0.48
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;
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.
server
ids
server=...
If the option end is set, all lines before __END__ are ignored in the test suite script. The option verbose adds more diagnostic messages.
end
__END__
verbose
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:
All lines starting with # are treated as comments.
#
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.
{
$server
$id
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.
key=value
key
id
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.
app.psgi
examples/daia-ubbielefeld.pl
Jakob Voss
This software is copyright (c) 2012 by Jakob Voss.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Plack::App::DAIA, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::App::DAIA
CPAN shell
perl -MCPAN -e shell install Plack::App::DAIA
For more information on module installation, please visit the detailed CPAN module installation guide.