change: add test

This commit is contained in:
lilong.129
2025-06-10 18:16:36 +08:00
parent 304abe653a
commit fa9a53d2ae
2 changed files with 37 additions and 3 deletions

View File

@@ -82,7 +82,7 @@ func TestAndroidAction(t *testing.T) {
assert.Nil(t, err)
}
func TestStartToGoal(t *testing.T) {
func TestGameLianliankan(t *testing.T) {
userInstruction := `连连看是一款经典的益智消除类小游戏,通常以图案或图标为主要元素。以下是连连看的基本规则说明:
1. 游戏目标: 玩家需要通过连接相同的图案或图标,将它们从游戏界面中消除。
2. 连接规则:
@@ -114,13 +114,47 @@ func TestStartToGoal(t *testing.T) {
StartToGoal(userInstruction, option.WithMaxRetryTimes(100)),
},
}
err := testCase.Dump2JSON("start_llk_game.json")
err := testCase.Dump2JSON("game_llk.json")
require.Nil(t, err)
err = hrp.NewRunner(t).Run(testCase)
assert.Nil(t, err)
}
func TestGame2048(t *testing.T) {
userInstruction := `2048 是一款数字合并类的益智小游戏,以下是它的基本规则:
1、游戏目标在一个 4x4 的网格中,通过合并相同数字的方块,最终得到一个数值为 2048 的方块。当然,若你能继续合并,也可追求更高的数字。
2、初始状态游戏开始时网格中会随机出现两个数字为 2 或 4 的方块。
3、移动操作玩家可以选择上、下、左、右四个方向进行移动。每次移动时所有方块会朝着指定方向滑动直到碰到边界或其他方块。
4、合并规则当两个相同数字的方块在移动过程中相遇时它们会合并成一个新的方块新方块的数值为原来两个方块数值之和。例如两个 2 合并成一个 4两个 4 合并成一个 8依此类推。
5、新方块生成每次移动结束后网格中会随机出现一个新的数字为 2 或 4 的方块。
6、注意事项若连续多次滑动无法生效请调整策略例如向上无法滑动可以尝试向下滑向左无法滑动可以尝试向右滑。
7、游戏结束当网格被填满且没有可合并的方块时游戏结束停止游戏。
请严格按照以上游戏规则,开始游戏
`
testCase := &hrp.TestCase{
Config: hrp.NewConfig("2048 小游戏自动化测试").
SetLLMService(option.DOUBAO_1_5_UI_TARS_250328),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音「2048经典」小游戏").
Android().
StartToGoal("启动抖音搜索「2048经典」小游戏并启动游戏").
Validate().
AssertAI("当前位于抖音「2048」小游戏页面"),
hrp.NewStep("开始游戏").
Android().
StartToGoal(userInstruction, option.WithMaxRetryTimes(100)),
},
}
err := testCase.Dump2JSON("game_2048.json")
require.Nil(t, err)
// err = hrp.NewRunner(t).Run(testCase)
// assert.Nil(t, err)
}
func TestAIAction(t *testing.T) {
testCase := &hrp.TestCase{
Config: hrp.NewConfig("run ui action with ai").