mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 17:29:56 +08:00
feat: support setup/teardown hooks
Change-Id: I148e11c190859b57dd5268cfe5643762e43bd64a
This commit is contained in:
@@ -34,8 +34,15 @@
|
||||
"variables": {
|
||||
"b": 34.5,
|
||||
"n": 3,
|
||||
"name": "get with params",
|
||||
"varFoo2": "${max($a, $b)}"
|
||||
},
|
||||
"setup_hooks": [
|
||||
"${setup_hook_example($name)}"
|
||||
],
|
||||
"teardown_hooks": [
|
||||
"${teardown_hook_example($name)}"
|
||||
],
|
||||
"extract": {
|
||||
"varFoo1": "body.args.foo1"
|
||||
},
|
||||
|
||||
@@ -24,7 +24,12 @@ teststeps:
|
||||
variables:
|
||||
b: 34.5
|
||||
"n": 3
|
||||
name: get with params
|
||||
varFoo2: ${max($a, $b)}
|
||||
setup_hooks:
|
||||
- ${setup_hook_example($name)}
|
||||
teardown_hooks:
|
||||
- ${teardown_hook_example($name)}
|
||||
extract:
|
||||
varFoo1: body.args.foo1
|
||||
validate:
|
||||
|
||||
@@ -55,3 +55,11 @@ func Concatenate(args ...interface{}) (interface{}, error) {
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func SetupHookExample(args string) string {
|
||||
return fmt.Sprintf("step name: %v, setup...", args)
|
||||
}
|
||||
|
||||
func TeardownHookExample(args string) string {
|
||||
return fmt.Sprintf("step name: %v, teardown...", args)
|
||||
}
|
||||
|
||||
@@ -10,5 +10,7 @@ func main() {
|
||||
plugin.Register("sum_two_string", SumTwoString)
|
||||
plugin.Register("sum_strings", SumStrings)
|
||||
plugin.Register("concatenate", Concatenate)
|
||||
plugin.Register("setup_hook_example", SetupHookExample)
|
||||
plugin.Register("teardown_hook_example", TeardownHookExample)
|
||||
plugin.Serve()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user