change: add test for sleep random

This commit is contained in:
debugtalk 2023-02-13 22:34:45 +08:00
parent 8d4e0357c8
commit c141b18606
2 changed files with 134 additions and 0 deletions

View File

@ -0,0 +1,84 @@
{
"config": {
"name": "点播_抖音_滑动场景_随机间隔_android",
"variables": {
"device": "${ENV(SerialNumber)}"
},
"android": [
{
"serial": "$device"
}
]
},
"teststeps": [
{
"name": "启动抖音",
"android": {
"actions": [
{
"method": "app_terminate",
"params": "com.ss.android.ugc.aweme"
},
{
"method": "app_launch",
"params": "com.ss.android.ugc.aweme"
},
{
"method": "sleep",
"params": 10
}
]
}
},
{
"name": "处理青少年弹窗",
"android": {
"actions": [
{
"method": "tap_ocr",
"params": "我知道了",
"ignore_NotFoundError": true
}
]
}
},
{
"name": "滑动 Feed 35 次,随机间隔 0-20s",
"android": {
"actions": [
{
"method": "swipe",
"params": "up"
},
{
"method": "sleep_random",
"params": [
0,
20
]
}
]
},
"loops": 35
},
{
"name": "滑动 Feed 15 次,随机间隔 15-50s",
"android": {
"actions": [
{
"method": "swipe",
"params": "up"
},
{
"method": "sleep_random",
"params": [
15,
50
]
}
]
},
"loops": 15
}
]
}

View File

@ -0,0 +1,50 @@
//go:build localtest
package uitest
import (
"testing"
"github.com/httprunner/httprunner/v4/hrp"
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
)
func TestAndroidDouyinFeedTest(t *testing.T) {
testCase := &hrp.TestCase{
Config: hrp.NewConfig("点播_抖音_滑动场景_随机间隔_android").
WithVariables(map[string]interface{}{
"device": "${ENV(SerialNumber)}",
}).
SetAndroid(uixt.WithSerialNumber("$device")),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音").
Android().
AppTerminate("com.ss.android.ugc.aweme").
AppLaunch("com.ss.android.ugc.aweme").
Sleep(10),
hrp.NewStep("处理青少年弹窗").
Android().
TapByOCR("我知道了", uixt.WithIgnoreNotFoundError(true)),
hrp.NewStep("滑动 Feed 35 次,随机间隔 0-20s").
Loop(35).
Android().
SwipeUp().
SleepRandom(0, 20),
hrp.NewStep("滑动 Feed 15 次,随机间隔 15-50s").
Loop(15).
Android().
SwipeUp().
SleepRandom(15, 50),
},
}
if err := testCase.Dump2JSON("demo_feed_random_slide.json"); err != nil {
t.Fatal(err)
}
runner := hrp.NewRunner(t).SetSaveTests(true)
err := runner.Run(testCase)
if err != nil {
t.Fatal(err)
}
}