接口测试
This commit is contained in:
parent
02c8ef307b
commit
33c781d457
@ -68,7 +68,7 @@ var (
|
|||||||
mainType: string(comm.ModuleHero),
|
mainType: string(comm.ModuleHero),
|
||||||
subType: hero.HeroSubTypeChouka,
|
subType: hero.HeroSubTypeChouka,
|
||||||
req: &pb.HeroChoukaReq{
|
req: &pb.HeroChoukaReq{
|
||||||
HeroIds: []int32{42911},
|
HeroIds: []int32{14001, 14002, 14003, 14004, 14005, 14006, 14007},
|
||||||
},
|
},
|
||||||
rsp: &pb.HeroChoukaResp{},
|
rsp: &pb.HeroChoukaResp{},
|
||||||
// enabled: true,
|
// enabled: true,
|
||||||
@ -78,7 +78,7 @@ var (
|
|||||||
subType: hero.HeroSubTypeList,
|
subType: hero.HeroSubTypeList,
|
||||||
req: &pb.HeroListReq{},
|
req: &pb.HeroListReq{},
|
||||||
rsp: &pb.HeroListResp{},
|
rsp: &pb.HeroListResp{},
|
||||||
enabled: true,
|
// enabled: true,
|
||||||
next: func(robot *Robot, rsp proto.Message) {
|
next: func(robot *Robot, rsp proto.Message) {
|
||||||
if r, ok := rsp.(*pb.HeroListResp); ok {
|
if r, ok := rsp.(*pb.HeroListResp); ok {
|
||||||
tcs := []*TestCase{}
|
tcs := []*TestCase{}
|
||||||
@ -94,11 +94,13 @@ var (
|
|||||||
HeroRace: []*pb.CostCardData{
|
HeroRace: []*pb.CostCardData{
|
||||||
{
|
{
|
||||||
CostCardObj: heroId,
|
CostCardObj: heroId,
|
||||||
|
Amount: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Hero: []*pb.CostCardData{
|
Hero: []*pb.CostCardData{
|
||||||
{
|
{
|
||||||
CostCardObj: heroId,
|
CostCardObj: heroId,
|
||||||
|
Amount: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -111,18 +113,35 @@ var (
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
desc: "英雄列表",
|
||||||
// enabled: true,
|
|
||||||
}, {
|
|
||||||
mainType: string(comm.ModuleHero),
|
mainType: string(comm.ModuleHero),
|
||||||
subType: hero.StrengthenUplv,
|
subType: hero.HeroSubTypeList,
|
||||||
req: &pb.HeroStrengthenUplvReq{
|
req: &pb.HeroListReq{},
|
||||||
HeroObjID: "62bd0489ff6632434a7d0d1f",
|
rsp: &pb.HeroListResp{},
|
||||||
ExpCardID: "62bd0b4eca37634b8230d4be",
|
enabled: true,
|
||||||
Amount: 1,
|
next: func(robot *Robot, rsp proto.Message) {
|
||||||
|
if r, ok := rsp.(*pb.HeroListResp); ok {
|
||||||
|
tcs := []*TestCase{}
|
||||||
|
// selHero := r.List[0] //选中的英雄
|
||||||
|
for _, v := range r.List {
|
||||||
|
heroId := v.Id
|
||||||
|
tc := &TestCase{
|
||||||
|
desc: "英雄升级",
|
||||||
|
mainType: string(comm.ModuleHero),
|
||||||
|
subType: hero.StrengthenUplv,
|
||||||
|
req: &pb.HeroStrengthenUplvReq{
|
||||||
|
HeroObjID: heroId,
|
||||||
|
ExpCardID: "62d124700625e43054ba307d",
|
||||||
|
Amount: 1,
|
||||||
|
},
|
||||||
|
rsp: &pb.HeroStrengthenUplvResp{},
|
||||||
|
enabled: true,
|
||||||
|
}
|
||||||
|
tcs = append(tcs, tc)
|
||||||
|
}
|
||||||
|
robot.addBuilders(tcs)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rsp: &pb.HeroStrengthenUplvResp{},
|
|
||||||
// enabled: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -53,6 +53,7 @@ func initlog() {
|
|||||||
writers := []io.Writer{
|
writers := []io.Writer{
|
||||||
file,
|
file,
|
||||||
os.Stdout}
|
os.Stdout}
|
||||||
|
|
||||||
//同时写文件和屏幕
|
//同时写文件和屏幕
|
||||||
fileAndStdoutWriter := io.MultiWriter(writers...)
|
fileAndStdoutWriter := io.MultiWriter(writers...)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -93,12 +94,6 @@ func (r *Robot) Run() {
|
|||||||
r.AccountLogin()
|
r.AccountLogin()
|
||||||
}
|
}
|
||||||
|
|
||||||
// go func() {
|
|
||||||
// for {
|
|
||||||
// r.handleRsp()
|
|
||||||
// }
|
|
||||||
// }()
|
|
||||||
|
|
||||||
ticker := time.NewTicker(time.Second * 5)
|
ticker := time.NewTicker(time.Second * 5)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@ -120,18 +115,17 @@ 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
|
print func(rsp proto.Message) //定义打印
|
||||||
print func(rsp proto.Message) //定义打印
|
next func(robot *Robot, rsp proto.Message) //处理下一层用例请求
|
||||||
next func(robot *Robot, rsp proto.Message) //处理下一层用例请求
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加测试用用例
|
//添加测试用用例
|
||||||
@ -162,7 +156,6 @@ func (r *Robot) handleReq() {
|
|||||||
for _, b := range r.builderMap {
|
for _, b := range r.builderMap {
|
||||||
if b.enabled && b.req != nil {
|
if b.enabled && b.req != nil {
|
||||||
time.Sleep(time.Millisecond * 500)
|
time.Sleep(time.Millisecond * 500)
|
||||||
// r.reqCh <- b.id
|
|
||||||
b.start = time.Now()
|
b.start = time.Now()
|
||||||
r.start = time.Now()
|
r.start = time.Now()
|
||||||
head := &pb.UserMessage{MainType: b.mainType, SubType: b.subType}
|
head := &pb.UserMessage{MainType: b.mainType, SubType: b.subType}
|
||||||
@ -229,7 +222,6 @@ func (r *Robot) handleRsp(id string) {
|
|||||||
uuid = id
|
uuid = id
|
||||||
}
|
}
|
||||||
|
|
||||||
// uuid := <-r.reqCh
|
|
||||||
r.handleNotify(uuid, msg)
|
r.handleNotify(uuid, msg)
|
||||||
if v, ok := r.builderMap[uuid]; ok {
|
if v, ok := r.builderMap[uuid]; ok {
|
||||||
if v.enabled &&
|
if v.enabled &&
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package robot
|
package robot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/modules/task"
|
"go_dreamfactory/modules/task"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
@ -12,7 +11,6 @@ import (
|
|||||||
var (
|
var (
|
||||||
taskBuilders = []*TestCase{
|
taskBuilders = []*TestCase{
|
||||||
{
|
{
|
||||||
//list
|
|
||||||
desc: "任务列表",
|
desc: "任务列表",
|
||||||
mainType: string(comm.ModuleTask),
|
mainType: string(comm.ModuleTask),
|
||||||
subType: task.TaskSubTypeList,
|
subType: task.TaskSubTypeList,
|
||||||
@ -20,13 +18,19 @@ var (
|
|||||||
TaskTag: int32(comm.TASK_DAILY),
|
TaskTag: int32(comm.TASK_DAILY),
|
||||||
},
|
},
|
||||||
rsp: &pb.TaskListResp{},
|
rsp: &pb.TaskListResp{},
|
||||||
print: func(rsp proto.Message) {
|
// print: func(rsp proto.Message) {
|
||||||
out := rsp.(*pb.TaskListResp)
|
// out := rsp.(*pb.TaskListResp)
|
||||||
for _, v := range out.List {
|
// for _, v := range out.List {
|
||||||
fmt.Printf("%v \n", v)
|
// fmt.Printf("%v \n", v)
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
// enabled: true,
|
// enabled: true,
|
||||||
|
next: func(robot *Robot, rsp proto.Message) {
|
||||||
|
tcs := []*TestCase{}
|
||||||
|
if _, ok := rsp.(*pb.TaskListResp); ok {
|
||||||
|
}
|
||||||
|
robot.addBuilders(tcs)
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
desc: "领取任务奖励",
|
desc: "领取任务奖励",
|
||||||
mainType: string(comm.ModuleTask),
|
mainType: string(comm.ModuleTask),
|
||||||
|
Loading…
Reference in New Issue
Block a user