自动调试脚本
上传文件,
打开软件处理文件,
关闭软件,
拉取处理结果,
对结果处理
func TestAdbPush(t *testing.T) {
Do([]string{"push", "./AAA.txt", "/storage/emulated/0/"})
}
func TestAdbPull(t *testing.T) {
Do([]string{"pull", "/storage/emulated/0/AAA.txt", "./"})
}
func TestAdbPullFile(t *testing.T) {
Do([]string{"pull", "/storage/emulated/0/Result.txt", "./"})
}
func Do(command []string) {
cmd := exec.Command("adb", command...)
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf("combined out:\n%s\n", string(out))
fmt.Printf("cmd.Run() failed with %s\n", err)
return
}
fmt.Printf("combined out:\n%s\n", string(out))
}
func TestStart(t *testing.T) {
Do([]string{"shell", "am", "start", "-n", "com.android.authtest/com.android.authtest.ui.mainPage.LoginActivity"})
}
func TestStop(t *testing.T) {
Do([]string{"shell", "am", "force-stop", "com.android.authtest"})
}
//adb shell am start -n com.android.authtest/com.android.authtest.ui.mainPage.LoginActivity
//adb shell am force-stop com.android.authtest
func TestFull(t *testing.T) {
Do([]string{"push", "./AAA.txt", "/storage/emulated/0/"})
Do([]string{"shell", "am", "start", "-n", "com.android.authtest/com.android.authtest.ui.mainPage.LoginActivity"})
time.Sleep(time.Second)
Do([]string{"shell", "am", "force-stop", "com.android.authtest"})
Do([]string{"pull", "/storage/emulated/0/Result.txt", "./"})
}