mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-07 15:31:23 +08:00
feat: add TCase struct for json loading and dumping
This commit is contained in:
63
models.go
63
models.go
@@ -14,44 +14,50 @@ const (
|
|||||||
|
|
||||||
type TConfig struct {
|
type TConfig struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Verify bool `json:"verify"`
|
Verify bool `json:"verify,omitempty"`
|
||||||
BaseURL string `json:"base_url"`
|
BaseURL string `json:"base_url,omitempty"`
|
||||||
Variables map[string]interface{} `json:"variables"`
|
Variables map[string]interface{} `json:"variables,omitempty"`
|
||||||
Parameters map[string]interface{} `json:"parameters"`
|
Parameters map[string]interface{} `json:"parameters,omitempty"`
|
||||||
Export []string `json:"export"`
|
Export []string `json:"export,omitempty"`
|
||||||
Weight int `json:"weight"`
|
Weight int `json:"weight,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TRequest struct {
|
type TRequest struct {
|
||||||
Method enumHTTPMethod `json:"method"`
|
Method enumHTTPMethod `json:"method"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Params map[string]interface{} `json:"params"`
|
Params map[string]interface{} `json:"params,omitempty"`
|
||||||
Headers map[string]string `json:"headers"`
|
Headers map[string]string `json:"headers,omitempty"`
|
||||||
Cookies map[string]string `json:"cookies"`
|
Cookies map[string]string `json:"cookies,omitempty"`
|
||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data,omitempty"`
|
||||||
JSON interface{} `json:"json"`
|
JSON interface{} `json:"json,omitempty"`
|
||||||
Timeout float32 `json:"timeout"`
|
Timeout float32 `json:"timeout,omitempty"`
|
||||||
AllowRedirects bool `json:"allow_redirects"`
|
AllowRedirects bool `json:"allow_redirects,omitempty"`
|
||||||
Verify bool `json:"verify"`
|
Verify bool `json:"verify,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TValidator struct {
|
type TValidator struct {
|
||||||
Check string // get value with jmespath
|
Check string `json:"check,omitempty"` // get value with jmespath
|
||||||
Assert string
|
Assert string `json:"assert,omitempty"`
|
||||||
Expect interface{}
|
Expect interface{} `json:"expect,omitempty"`
|
||||||
Message string
|
Message string `json:"msg,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TStep struct {
|
type TStep struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Request *TRequest `json:"request"`
|
Request *TRequest `json:"request,omitempty"`
|
||||||
TestCase *TestCase `json:"testcase"`
|
TestCase *TestCase `json:"testcase,omitempty"`
|
||||||
Variables map[string]interface{} `json:"variables"`
|
Variables map[string]interface{} `json:"variables,omitempty"`
|
||||||
SetupHooks []string `json:"setup_hooks"`
|
SetupHooks []string `json:"setup_hooks,omitempty"`
|
||||||
TeardownHooks []string `json:"teardown_hooks"`
|
TeardownHooks []string `json:"teardown_hooks,omitempty"`
|
||||||
Extract map[string]string `json:"extract"`
|
Extract map[string]string `json:"extract,omitempty"`
|
||||||
Validators []TValidator `json:"validators"`
|
Validators []TValidator `json:"validate,omitempty"`
|
||||||
Export []string `json:"export"`
|
Export []string `json:"export,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// used for testcase json loading and dumping
|
||||||
|
type TCase struct {
|
||||||
|
Config TConfig `json:"config"`
|
||||||
|
TestSteps []*TStep `json:"teststeps"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// interface for all types of steps
|
// interface for all types of steps
|
||||||
@@ -61,9 +67,10 @@ type IStep interface {
|
|||||||
ToStruct() *TStep
|
ToStruct() *TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used for testcase runner
|
||||||
type TestCase struct {
|
type TestCase struct {
|
||||||
Config TConfig `json:"config"`
|
Config TConfig
|
||||||
TestSteps []IStep `json:"teststeps"`
|
TestSteps []IStep
|
||||||
}
|
}
|
||||||
|
|
||||||
type TestCaseSummary struct{}
|
type TestCaseSummary struct{}
|
||||||
|
|||||||
Reference in New Issue
Block a user