Parameter types
GoBDD has support for parameter types. There are a few predefined parameter types:
{int}
- integer (-1 or 56){float}
- float (0.4 or 234.4){word}
- single word (hello
orpizza
){text}
- single-quoted or double-quoted strings ('I like pizza!'
or"I like pizza!"
)
You can add your own parameter types using AddParameterTypes()
function. Here are a few examples
s := gobdd.NewSuite(t)
s.AddParameterTypes(`{int}`, []string{`(-?\d+)`})
s.AddParameterTypes(`{float}`, []string{`([-+]?\d*\.?\d+)`})
s.AddParameterTypes(`{word}`, []string{`([^\s]+)`})
s.AddParameterTypes(`{text}`, []string{`"([^"\\]*(?:\\.[^"\\]*)*)"`, `'([^'\\]*(?:\\.[^'\\]*)*)'`})
The first argument accepts the parameter types. As the second parameter provides list of regular expressions that should replace the parameter.
Parameter types should be added Before adding any step.