-
Notifications
You must be signed in to change notification settings - Fork 2
Templates
Madcow 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.
Templates are properties files defined outside of the default Madcow test folder - by default, under templates.
They support the same syntax and operations as a normal Madcow properties file test, with the main difference being that are not run as part of the collection of tests.
CountryTemplate.properties:
searchResults.table.selectRow = ['Country' : 'New Zealand']
searchResults.table.currentRow.checkValue = ['Country' : 'New Zealand', 'lastColumn' : 'NZD']
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:
testInfo = Test various countries
import = CountryTemplate
When executed, this will expand to
testInfo = Test various countries
searchResults.table.selectRow = ['Country' : 'New Zealand']
searchResults.table.currentRow.checkValue = ['Country' : 'New Zealand', 'lastColumn' : 'NZD']
When importing a template, exclude the .properties file extension!
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.
searchResults.table.selectRow = ['Country' : @selectedCountry]
searchResults.table.currentRow.checkValue = ['Country' : '@selectedCountry', 'lastColumn' : '@selectedCountryCurrency']
testInfo = Test various countries
@selectedCountry = Australia
@selectedCountryCurrency = AUD
import = CountryTemplate
@selectedCountry = New Zealand
@selectedCountryCurrency = NZD
import = CountryTemplate
@selectedCountry = United States of America
@selectedCountryCurrency = USD
import = CountryTemplate
testInfo = Test various countries
searchResults.table.selectRow = ['Country' : 'Australia']
searchResults.table.currentRow.checkValue = ['Country' : 'Australia', 'lastColumn' : 'AUD']
searchResults.table.selectRow = ['Country' : 'New Zealand']
searchResults.table.currentRow.checkValue = ['Country' : 'New Zealand', 'lastColumn' : 'NZD']
searchResults.table.selectRow = ['Country' : 'United States of America']
searchResults.table.currentRow.checkValue = ['Country' : 'United States of America', 'lastColumn' : 'USD']
In order to maxamise the flexibility of templates, you can define a default value for any of the parameters used in the template. You can define a default value for a parmeter like so \{parameterName\}.default=\{parameterValue\}. The following example illustrates how.
- Home
- Setting Up
- Configuration
- Writing Madcow Tests
- Running Madcow Tests
- Data Parameters
- Templates
- Macros
- Disabling A Test
- Spreadsheet Scenario Testing
Madcow Operations
- Madcow Operations
- Madcow Operations - Table
- Madcow Operations - XPath Extras
- List of Madcow Operations
Extending and Customising Madcow
Reference
For Developers