test_tool

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckParamWithResult

func CheckParamWithResult(t *testing.T, queryObj interface{}, respData interface{})

CheckParamWithResult 判断query参数中(例如type=0&country=CA&sort=1)的参数值与返回的json结果中的值是否一致。 适用于:responseData中仅有1个实例,例如机构详细信息的返回值(不是机构列表信息) 注意:仅适用于返回的结果中的数据项类型是int/string/bool 注意:需要在struct中加tag `query_name:"xxx" result_name:"xxx" assert:"xxx"` 其中后两者可选填 如果返回值data是结构体,则result_name设置成结构体的field_name(大写),如果返回data是map,则result_name是map的key_name(小写) assert tag如果不加,则默认值assert:"equal", 其他项目为notEmpty query_name是指在请求的参数中的参数名,result_name指在返回的json 结果中的参数名

func CheckParamWithResults

func CheckParamWithResults(t *testing.T, queryObj interface{}, respDataArray []interface{})

CheckParamWithResults 判断query参数中(例如type=0&country=CA&sort=1)的参数值与返回的json结果中的值是否一致。 适用于:responseData中是实例的列表,例如机构列表信息的返回值(不是机构详细信息) 注意:仅适用于返回的结果中的数据项类型是int/string/bool 注意:需要在struct中加tag `query_name:"xxx" result_name:"xxx"` 如果返回值data是结构体,则result_name设置成结构体的field_name(大写),如果返回data是map,则result_name是map的key_name(小写) query_name是指在请求的参数中的参数名,result_name指在返回的json 结果中的参数名

func GetParams

func GetParams(queryObj interface{}) url.Values

GetParams 用于提供一个query param struct(queryObj),得到一个用于encode的params。 注意:需要在struct中加tag `query_name:"xxx"`!!

例如,提供struct{
		Type string `query_name:"type"`
		Featured string `query_name:"featured"`
		Country string `query_name:"country"`
		Sort string `query_name:"sort"`
		PageSize string `query_name:"page_size"`
		Page string `query_name:"page"`}

得到的params可以用于params.encode(),进而得到 type=0&country=CA&sort=1

func GetSubTestName

func GetSubTestName(queryObj interface{}) (subtestName string)

GetSubTestName 用于在table driven tests中,给子测试命名,queryObj为每一个test cases中的结构体实例 注意:需要在struct中加tag `query_name:"xxx"`!!

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL