Documentation ¶
Overview ¶
* v1_jsonbody 兼容 apitestsv1 里的 json body 渲染逻辑: - 反序列化,当类型是 map 或 slice 时进行处理 - value(map 的 value、slice 的 value) 必须**全量匹配** {{.+}},不支持 {{.+}}xxx 这种 - 匹配之后,替换时根据配置的具体类型进行渲染
举例: - 例如 map 有一组 kv 为 "key1": "{{ticketID}}"
- 若参数 ticketID 为 integer(10),渲染结果为 "key1": 10
- 若参数 ticketID 为 string("10"),渲染结果为 "key1": "10"
- 假如 map 有一组 kv 为 "key1": {{ticketID}}
- 此时反序列化失败,不进行 v1 渲染
- 此时走 v2 渲染逻辑,即文本渲染。若参数为 ticketID=10
- "key1": {{ticketID}} => "key1": 10
- "key1": "{{ticketID}}" => "key1": "10"
- "key1": "{{ticketID}}-xxx" => "key1": "10-xxx"
- "key1": {{ticketID}}-xxx => "key1": 10-xxx
Index ¶
- Constants
- type APIParam
- type APITest
- func (at *APITest) Invoke(httpClient *http.Client, testEnv *apistructs.APITestEnvData, ...) (*apistructs.APIRequestInfo, *apistructs.APIResp, error)
- func (at *APITest) JudgeAsserts(outParams map[string]interface{}, asserts []apistructs.APIAssert) (bool, []*apistructs.APITestsAssertData)
- func (at *APITest) ParseOutParams(apiOutParams []apistructs.APIOutParam, apiResp *apistructs.APIResp, ...) map[string]interface{}
- type OpOption
Constants ¶
View Source
const HeaderCookie = "Cookie"
View Source
const HeaderSetCookie = "Set-Cookie"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APITest ¶
type APITest struct { // dice api test 声明,包括入参、出参、断言等 API *apistructs.APIInfo // 运行时结果,包括 response、断言结果、接口测试结果等 APIResult *apistructs.ApiTestInfo // contains filtered or unexported fields }
APITest API 测试的结构信息
func (*APITest) Invoke ¶
func (at *APITest) Invoke(httpClient *http.Client, testEnv *apistructs.APITestEnvData, caseParams map[string]*apistructs.CaseParams) ( *apistructs.APIRequestInfo, *apistructs.APIResp, error)
Invoke 执行 API 测试
func (*APITest) JudgeAsserts ¶
func (at *APITest) JudgeAsserts(outParams map[string]interface{}, asserts []apistructs.APIAssert) (bool, []*apistructs.APITestsAssertData)
JudgeAsserts 执行断言测试
func (*APITest) ParseOutParams ¶
func (at *APITest) ParseOutParams(apiOutParams []apistructs.APIOutParam, apiResp *apistructs.APIResp, caseParams map[string]*apistructs.CaseParams) map[string]interface{}
ParseOutParams 解析 API 执行结果的出参,存储为全局变量,供后续使用
type OpOption ¶
type OpOption func(*option)
func WithNetportalConfigs ¶
WithNetportalConfigs set netportal url, whitelist and others.
func WithTryV1RenderJsonBodyFirst ¶
func WithTryV1RenderJsonBodyFirst() OpOption
WithTryV1RenderJsonBodyFirst 尝试先使用 v1 严格模式渲染 json body。不论是否打开开关,都会再使用 v2 逻辑渲染一遍。 为手动测试的接口测试提供兼容处理;自动化测试无需打开该开关。
Source Files ¶
Click to show internal directories.
Click to hide internal directories.