Files
httprunner/examples/game/romantic_restaurant/main_test.go
2025-07-04 14:23:09 +08:00

57 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package game_romantic_restaurant
import (
"testing"
"github.com/stretchr/testify/require"
hrp "github.com/httprunner/httprunner/v5"
"github.com/httprunner/httprunner/v5/uixt/option"
)
func TestGameRomanticRestaurant(t *testing.T) {
userInstruction := `浪漫餐厅是一款经营类游戏,以下是游戏的基本规则说明:
1、点击右下角锅铲开始任务
2、将棋子拖拽至相同棋子可升级生成新棋子
3、拖拽相同棋子时被部分遮挡的棋子只能作为拖拽终点不能作为拖拽起点
4、当游戏界面中没有相同棋子时可以点击游戏页面中央的购物袋生成新的棋子
5、若不知道如何操作请按照游戏指引进行游玩
请严格按照以上游戏规则,开始游戏
`
testCase := &hrp.TestCase{
Config: hrp.NewConfig("浪漫餐厅小游戏自动化测试").
SetLLMService(option.DOUBAO_1_5_THINKING_VISION_PRO_250428).
WithVariables(map[string]interface{}{
"package_name": "com.ss.android.ugc.aweme",
}),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音 app").
Android().
AppLaunch("$package_name").
Sleep(5).
Validate().
AssertAppInForeground("$package_name"),
hrp.NewStep("进入「浪漫餐厅」小游戏").
Android().
StartToGoal("搜索「浪漫餐厅」,进入小游戏",
option.WithPreMarkOperation(true)).
Validate().
AssertAI("当前位于游戏界面"),
hrp.NewStep("开始游戏").
Android().
StartToGoal(userInstruction,
option.WithPreMarkOperation(true),
option.WithTimeLimit(300)), // 5 minutes
hrp.NewStep("退出抖音 app").
Android().
AppTerminate("$package_name"),
},
}
err := testCase.Dump2JSON("game_romantic_restaurant.json")
require.Nil(t, err)
// err = hrp.NewRunner(t).Run(testCase)
// assert.Nil(t, err)
}