Macros

Inline executable bits of helpful code


Macros give us the power to evaluate some groovy code, and have the result used in a Madcow step. This feature is simple, but extremely powerful.

Be aware, though, that it’ll greatly reduce the maintainability of your scripts for people who don’t know Groovy.

Examples

#Set a parameter called currentDate to have to the value of the current date
@currentDate=madcow.eval({ new Date().format('dd/MM/yyyy')})

#Set the accident time field to be the current time
accidentpage_accidentTime.setValue = madcow.eval({ new Date().format("H:m:ss") })

#Read the contents of the description file and input it into the description field
accidentpage_accidentDescription.setValue = madcow.eval({ new File('/tmp/descriptionFile.txt').getText() })