Resuable steps that can be imported and overridden - unleash the power!
Documentation /
Templates
Madcow 2.0 provides the ability to define a set of templates, which can be imported into a test. This allows for a common set of test functions to be defined and reused throughout multiple tests.
Defining a Template
Templates are properties files defined outside of the default Madcow 2.0 test folder - by default, under templates.
They support the same syntax and operations as a normal Madcow 2.0 GRASS file test, with the main difference being that are not run as part of the collection of tests.
Using a Template
A template is included into a Test file, using the Madcow syntax of import.
This will put all the contents of the specified template into the test.
To import a template named CountryTemplate:
When executed, this will expand to
When importing a template, exclude the .grass file extension!
Data Parameters and Templates
As templates support all Madcow operations, they support the use of Data Parameters.
This enables the user to create generic functionality, which can be reused by altering the data passed to the template from a test.
Building on the examples previously, we could pass through the currency and country being searched for in the template from our test.
Country Template
CountryTest
Expanded version of CountryTest
Default Values for Parameters in Templates
In order to maxamise the flexibility of templates, we can define a default value for any of the parameters used in the template. This allows us to only override the parameters that we want to change.
You can define a default value for a parmeter like so: {parameterName}.default={parameterValue}. The following example illustrates in more detail.