接口 测试

This commit is contained in:
zhaocy 2022-07-15 15:23:19 +08:00
parent acc2231213
commit a848e14987
3 changed files with 25 additions and 20 deletions

12
cmd/robot/assistant.go Normal file
View File

@ -0,0 +1,12 @@
package robot
// 场景:在测试的接口中,输入参数为了能达到自动化,都是从业务中已有的协议中返回获取,作为下一个协议的输入参数。
// 但是会存在协议中的输入参数无法从上一个协议中获取比如添加好友协议输入参数是“目标玩家ID”为了能够动态
// 测试添加好友协议,如果专门为这个协议添加返回目标玩家的接口,显然有点不合适。一个方案是,设计一个助手,专门处
// 理这类问题,这个助手可以返回合适的数据,作为输入参数。
type assistant struct {
//TODO
}

View File

@ -95,13 +95,6 @@ var (
} }
}, },
}, {
desc: "删除黑名单",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeDelBlack,
req: &pb.FriendDelBlackReq{},
rsp: &pb.FriendDelBlackResp{},
// enabled: true,
}, },
} }
) )

View File

@ -120,18 +120,18 @@ func (r *Robot) Run() {
} }
type TestCase struct { type TestCase struct {
id string //用例ID 如果没有指定,会自动赋值uuid id string //用例ID 如果没有指定,会自动赋值uuid
desc string //用例描述 desc string //用例描述
mainType string //协议类型 L1 mainType string //协议类型 L1
subType string //协议类型 L2 subType string //协议类型 L2
req proto.Message //请求类型 req proto.Message //请求类型
rsp proto.Message //响应类型 rsp proto.Message //响应类型
enabled bool //是否启用 enabled bool //是否启用
start time.Time //启用时间 start time.Time //启用时间
hs time.Duration //耗时 hs time.Duration //耗时
requested bool //是否是请求的case // requested bool //是否是请求的case
print func(rsp proto.Message) //定义打印 print func(rsp proto.Message) //定义打印
next func(robot *Robot, rsp proto.Message) //处理下一层用例请求 next func(robot *Robot, rsp proto.Message) //处理下一层用例请求
} }
//添加测试用用例 //添加测试用用例
@ -160,7 +160,7 @@ func (r *Robot) handleReq() {
// go func() { // go func() {
for len(r.builderMap) > 0 { for len(r.builderMap) > 0 {
for _, b := range r.builderMap { for _, b := range r.builderMap {
if b.enabled && b.req != nil && !b.requested { if b.enabled && b.req != nil {
time.Sleep(time.Millisecond * 500) time.Sleep(time.Millisecond * 500)
// r.reqCh <- b.id // r.reqCh <- b.id
b.start = time.Now() b.start = time.Now()