Files
httprunner/examples/game/romantic_restaurant/main_test.go
2025-07-06 10:38:50 +08:00

65 lines
2.4 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、若不知道如何操作请按照游戏指引进行游玩
6、不要连续重复上一步操作合成失败后及时更换策略
请严格按照以上游戏规则,开始游戏
`
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("搜索「浪漫餐厅」点击进入「游戏」tab进入小游戏",
// option.WithPreMarkOperation(true)).
// Validate().
// AssertAI("当前位于游戏界面"),
hrp.NewStep("进入「浪漫餐厅」小游戏").
Android().
Home().
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)
}