mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-14 20:08:23 +08:00
feat: call function with one argument
This commit is contained in:
@@ -281,6 +281,7 @@ func TestMergeVariables(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCallFunction(t *testing.T) {
|
||||
// call function without arguments
|
||||
funcName := "sleep"
|
||||
params := []interface{}{1}
|
||||
timeStart := time.Now()
|
||||
@@ -291,4 +292,15 @@ func TestCallFunction(t *testing.T) {
|
||||
if !assert.Greater(t, time.Since(timeStart), time.Duration(1)*time.Second) {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
// call function with one argument
|
||||
funcName = "gen_random_string"
|
||||
params = []interface{}{10}
|
||||
result, err := callFunction(funcName, params)
|
||||
if !assert.Nil(t, err) {
|
||||
t.Fail()
|
||||
}
|
||||
if !assert.Equal(t, 10, len(result.(string))) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user