接口 测试
This commit is contained in:
parent
acc2231213
commit
a848e14987
12
cmd/robot/assistant.go
Normal file
12
cmd/robot/assistant.go
Normal file
@ -0,0 +1,12 @@
|
||||
package robot
|
||||
|
||||
// 场景:在测试的接口中,输入参数为了能达到自动化,都是从业务中已有的协议中返回获取,作为下一个协议的输入参数。
|
||||
// 但是会存在,协议中的输入参数无法从上一个协议中获取,比如:添加好友协议,输入参数是“目标玩家ID”,为了能够动态
|
||||
// 测试添加好友协议,如果专门为这个协议添加返回目标玩家的接口,显然有点不合适。一个方案是,设计一个助手,专门处
|
||||
// 理这类问题,这个助手可以返回合适的数据,作为输入参数。
|
||||
|
||||
type assistant struct {
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
@ -95,13 +95,6 @@ var (
|
||||
}
|
||||
|
||||
},
|
||||
}, {
|
||||
desc: "删除黑名单",
|
||||
mainType: string(comm.ModuleFriend),
|
||||
subType: friend.FriendSubTypeDelBlack,
|
||||
req: &pb.FriendDelBlackReq{},
|
||||
rsp: &pb.FriendDelBlackResp{},
|
||||
// enabled: true,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
@ -120,18 +120,18 @@ func (r *Robot) Run() {
|
||||
}
|
||||
|
||||
type TestCase struct {
|
||||
id string //用例ID 如果没有指定,会自动赋值uuid
|
||||
desc string //用例描述
|
||||
mainType string //协议类型 L1
|
||||
subType string //协议类型 L2
|
||||
req proto.Message //请求类型
|
||||
rsp proto.Message //响应类型
|
||||
enabled bool //是否启用
|
||||
start time.Time //启用时间
|
||||
hs time.Duration //耗时
|
||||
requested bool //是否是请求的case
|
||||
print func(rsp proto.Message) //定义打印
|
||||
next func(robot *Robot, rsp proto.Message) //处理下一层用例请求
|
||||
id string //用例ID 如果没有指定,会自动赋值uuid
|
||||
desc string //用例描述
|
||||
mainType string //协议类型 L1
|
||||
subType string //协议类型 L2
|
||||
req proto.Message //请求类型
|
||||
rsp proto.Message //响应类型
|
||||
enabled bool //是否启用
|
||||
start time.Time //启用时间
|
||||
hs time.Duration //耗时
|
||||
// requested bool //是否是请求的case
|
||||
print func(rsp proto.Message) //定义打印
|
||||
next func(robot *Robot, rsp proto.Message) //处理下一层用例请求
|
||||
}
|
||||
|
||||
//添加测试用用例
|
||||
@ -160,7 +160,7 @@ func (r *Robot) handleReq() {
|
||||
// go func() {
|
||||
for len(r.builderMap) > 0 {
|
||||
for _, b := range r.builderMap {
|
||||
if b.enabled && b.req != nil && !b.requested {
|
||||
if b.enabled && b.req != nil {
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
// r.reqCh <- b.id
|
||||
b.start = time.Now()
|
||||
|
Loading…
Reference in New Issue
Block a user