feat(api): 新增 RunSub 支持接口测试内部分场景
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -71,6 +71,22 @@ func (a *Api) AtPath(path string) *Api {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RunSub 在单个接口测试 Func 内再分子场景,便于 go test -run 收窄。
|
||||||
|
func (a *Api) RunSub(desc string, fn func(a *Api)) {
|
||||||
|
if a == nil || a.t == nil {
|
||||||
|
fn(a)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
a.t.Run(desc, func(t *testing.T) {
|
||||||
|
fn(&Api{
|
||||||
|
app: a.app,
|
||||||
|
path: a.path,
|
||||||
|
t: t,
|
||||||
|
session: a.session,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// JSON 设置 JSON body,返回 ApiCase 构建器
|
// JSON 设置 JSON body,返回 ApiCase 构建器
|
||||||
func (a *Api) JSON(body interface{}) *ApiCase {
|
func (a *Api) JSON(body interface{}) *ApiCase {
|
||||||
c := a.newCase()
|
c := a.newCase()
|
||||||
|
|||||||
Reference in New Issue
Block a user