Passing Information through Configuration
Version>=0.7.0

Tools, paths and context

rutema allows you to pass configuration information to the parser and the reporters following a few conventions along the way. The configuration object passed to the parser and the reporters offers three members: configuration.tools, configuration.paths and configuration.context

Tools

The configuration.tool directive allows you to pass information about the various tools/executables to be used by the parser.

configuration.tool={:name=>"cooltool",
:path=>"/opt/bin/cooltool",
:configuration=>{:coolness=>"high"}
}

In the parser configuration.tools.cooltool will return the
{:name=>"cooltool",
:path=>"/opt/bin/cooltool",
:configuration=>{:coolness=>"high"}}
Hash.

Consider the following example:
Several test cases are executed against a test server. In these specifications a database element is responsible for resetting the database with the appropriate data for the test.

One possible implementation is

<database script="test_data.sql" server="db001"/>

where the database in db001 is filled with the data from test_data.sql.

This is a simple approach, as the parser has all the information (the what,where and how) included in the definition of the step.
The test specification though is bound to the db001 server, meaning we need a copy with the server name changed if we decide to run the tests against a different server.
Additionaly adding extra information (like user and password for DB access) makes the step definitions even more unwieldy and increases the ammount of work needed to maintain the spec.

The where and how of the test executions should be managed in the configuration, so that a complete set of tests can be transfered to a different physical infrastructure just by changing the configuration.
So in this example the element should be even simpler

<database script="test_data.sql"/>

and the parser can use a tool configuration to create the execution environment:

configuration.tool={:name=>"database_update",
:configuration=>{:server=>"db001",:user=>"db_user",:password=>"foo"}
}

Paths

The configuration.path directive allows you to pass information about paths to be used by the parser.

configuration.path={:name=>"sources",:path=>"/path/to/sources"}
In the parser configuration.paths.sources will return "/path/to/sources". Only :name and :path are used.

Context

The configuration.context directive allows you to pass general information to the parser and the reporters. It's intended purpose is to allow you to define things like versions, author and tester names, possible filenames for use with reporters etc.
Keep in mind that the configuration file is Ruby code: the values assigned do not necessarily have to be static.

For example, the current build version can be deduced in the configuration by code and assigned to a context key ensuring that your reports will include the correct version with every execution.

configuration.context={:key1=>"value1",:key2=>some_method()}

In the parser/reporter configuration.context.key1 will return "value1"

Home
More...

Documentation
More...