-
Notifications
You must be signed in to change notification settings - Fork 2
Madcow best practices
Rather than copying sections of Grass scripts between test scripts, use data parameters, default parameters and templates to generalise the steps for re-use. Although this increases the complexity of writing a single script it has a number of advantages:
- If the "shared" page changes you only need to fix the shared template and not all the tests.
- Hide unimportant steps from the test making it easier to see what the test is doing.
- Save time when writing your next script.
- Give sections in your test meaningful names instead of Grass steps. e.g.
importTemplate = Login
....
In order to maximise the flexibility of templates, we usually use data parameters to specify the values for each operation used in the template. In order to prevent having to specify values for parameters that we don't care about, it's advisable to set default values for all parameters used in a given template. That way if a value hasn't been specified for the data parameter, the template will still function correctly.
The following example demonstrates setting default values for a template that will select a drivers name. If the calling test doesn't specify a value for @firstname or @lastname, then the driver name will be set to Joe Schmoe.
#-----------------------------#
# Select Driver Name Template #
#-----------------------------#
#Set defaults for the drivers name
@firstname.default = Joe
@lastname.default = Schmoee
#Navigate to the page
goToDriverPage.clickLink
#Set the drivers name
driverFirstName.value = @firstname
driverLastName.value = @lastname
Version Control Systems (VCS) like Subversion (SVN) or Git are useful additions to your test development. VCSs give you the ability to retrieve old versions of your tests, share tests with other testers, tag revisions of tests and, branch and merge tests.
Subversion is probably to simplest open-source VCS to learn. For more information see http://subversion.apache.org/
Spreadsheet tests are useful when you want to create multiple test scenarios with the only difference being the data used in each scenario. They are also useful if you wish to test certain algorithms or calculations being performed by the system under test as these can be modeled in the spreadsheet test.
Properties tests are more flexible than spreadsheet tests and should be used for most of the functional testing. As the test scenarios become more complex the use of data parameters and templates allows re-use of the test scripts as discussed above.
- 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