[本文出自天外归云的博客园]

简单封装下xcodebuild test命令,写一个执行xcode测试的go程序,可以设定单case执行次数,也可以二次组装调用进行多个case的测试,代码如下:

package main

import (
"flag"
"fmt"
"os/exec"
"strings"
) func qnegTestRunner(workspacePath string, scheme string, targetMethod string) (testResult int) {
targets := strings.Split(targetMethod, "/")
className := targets[1]
methodName := targets[2]
var err error
var cmd *exec.Cmd
var result []byte
commandString := fmt.Sprintf("xcodebuild test -workspace %s -scheme %s -destination 'platform=iOS Simulator,name=iPhone 7,OS=12.2' -only-testing:%s", workspacePath, scheme, targetMethod)
cmd = exec.Command("/bin/bash", "-c", commandString)
result, err = cmd.Output()
passedSign := fmt.Sprintf("'-[%s %s]' passed", className, methodName)
if strings.Contains(string(result), passedSign) {
testResult = 1
} else {
fmt.Println(commandString)
fmt.Println(strings.Trim(string(result), "\n"))
fmt.Println(err)
testResult = 0
}
return
} /*
终端执行该脚本命令如下:
go run exeTest.go -exeCount 3 -projectPath "/Users/admin/Desktop/zenki/XX" -scheme "Scheme" -targetMethod "Scheme/ClassName/methodName"
*/
func main() {
var targetMethod = flag.String("targetMethod", "", "目标方法")
var exeCount = flag.Int("exeCount", 3, "运行次数")
var projectPath = flag.String("projectPath", "/Users/admin/Desktop/zenki/XX", "项目路径")
var scheme = flag.String("scheme", "", "选择主题")
flag.Parse()
workspacePath := fmt.Sprintf("%s%s", *projectPath, "/XX.xcworkspace")
finalResult := 0
for index := 1; index <= *exeCount; index++ {
fmt.Println(fmt.Printf("[%d time execute] %s", index, *targetMethod))
finalResult += qnegTestRunner(workspacePath, *scheme, *targetMethod)
}
if finalResult == *exeCount {
fmt.Println(fmt.Sprintf("Execute %d times, all passed.", *exeCount))
} else {
fmt.Println(fmt.Sprintf("Execute %d times, %d times passed.", *exeCount, finalResult))
}
}

Xcodebuild稳定性测试go脚本的更多相关文章

  1. 移动性能测试 | 持续集成中的 Android 稳定性测试

    前言 谈到Android稳定测试,大多数会联想到使用monkey工具来做测试.google官方提供了monkey工具,可以很快速点击被应用,之前我有一篇帖子提到了monkey工具的使用,详见: htt ...

  2. Android-monkey稳定性测试(多台设备同时进行)

                                       1.目的(原创文章,转载请注明出处-) 主要为指引开展android平台应用的稳定性测试,尽可能地在应用发布前发现crash及an ...

  3. Android客户端稳定性测试——Monkey

    修改时间 修改内容 修改人 2016.6.20 创建 刘永志 2016.6.29 完成 刘永志 Monkey简介: Android SDK自带的命令行测试工具,向设备发送伪随机事件流,对应用程序进行进 ...

  4. [转贴]LTP--linux稳定性测试 linux性能测试 ltp压力测试 ---IBM 的 linux test project

    https://blog.csdn.net/melody157398/article/details/24354415   LTP--linux稳定性测试 linux性能测试 ltp压力测试 ---I ...

  5. 基于jmeter+perfmon的稳定性测试记录

    1. 引子 最近承接了项目中一些性能测试的任务,因此决定记录一下,将测试的过程和一些心得收录下来. 说起来性能测试算是软件测试行业内,有些特殊的部分.这部分的测试活动,与传统的测试任务差别是比较大的, ...

  6. Monkey 稳定性测试

    学习网址: https://blog.csdn.net/lucytan01/article/details/79958727 https://blog.csdn.net/hebbely/article ...

  7. 对Linux系统内核版本稳定性测试介绍

    对Linux系统内核版本稳定性测试介绍 在对 Linux 内核版本稳定性的测试中,需要明确地声明并证明为什么版本是稳定的或者是不稳定的. 然而还没有被证明和证实当前现有的系统范围内的压力测试可以测试 ...

  8. LTP--linux稳定性测试 linux性能测试 ltp压力测试 ---IBM 的 linux test project

    LTP--linux稳定性测试 linux性能测试 ltp压力测试 ---IBM 的 linux test project Peter盼 2014-04-23 11:25:49  20302  收藏  ...

  9. LTP--linux稳定性测试 linux性能测试 ltp压力测试 内核更新 稳定性测试

    LTP--linux稳定性测试 linux性能测试 ltp压力测试 zhangzj1030关注14人评论33721人阅读2011-12-09 12:07:45   说明:在写这篇文章之前,本人也不曾了 ...

随机推荐

  1. 【转】学习ARM为什么首选IMAX6??

    ARM作为目前嵌入式行业主流的架构,已经让越来越多从事电子行业的朋友了解,并且高校对于嵌入式的学习,很多直接从ARM开始,目前ARM的嵌入式培训也越来越多,足以说明现在嵌入式行业有多火.目前主流的AR ...

  2. Python xlrd模块读取Excel表中的数据

    1.xlrd库的安装 直接使用pip工具进行安装(当然也可以使用pycharmIDE进行安装,这里就不详述了) pip install xlrd 2.xlrd模块的一些常用命令 ①打开excel文件并 ...

  3. c#时间与时间戳互转13位

    Unix时间戳(Unix timestamp),或称Unix时间(Unix time).POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间1970年01月01日00时00 ...

  4. php责任链模式(The chain of responsibility pattern)

    送家人从火车站归来,继续码. <?php /* The chain of responsibility pattern decouples the sender of a request fro ...

  5. js--同步运动json上

    如何实现几个属性的同时变化?这个问题需要运用到json,这里我们先来简要的介绍一下json json的形式是这样的,他的元素是有一对对的键值对组成的{name1:value1,name2:value2 ...

  6. thinkPHP5框架路由常用知识点汇总

    一.路由的模式 普通模式(默认pathinfo,不解析路由) 'url_route_on' => false 混合模式(pathinfo+解析路由) 'url_route_on' => t ...

  7. autoRoll_UpDown()|上下滚动函数|无缝|自动(自带demo)

    autoRoll_UpDown函数 function autoRoll_UpDown($domObj,speed){ //$domObj 外围容器的jQuery式元素对象 speed 滚动速度,单位毫 ...

  8. jquery.lazyload.js-v1.9.1延时加载插件,已兼容ie6和各大浏览器

    来源:http://www.jq22.com/jquery-info390 使用前要求: img的设置: 1.class要配上“lazy”: 2.用data-original代替src: 3.如果想要 ...

  9. Servlet 容器

    Servlet容器主要是JavaWeb应用提供运行时环境,所以也可以称之为JavaWeb应用容器,或者Servlet/JSP容器.Servlet容器主要负责管理Servlet.JSP的生命周期以及它们 ...

  10. 22-1 web传输视频 Opencv+usb摄像头 树莓派+Flask实现视频流媒体WEB服务器

    第一篇 讲解原理 https://blog.miguelgrinberg.com/post/video-streaming-with-flask 第二篇 加入多线程可以直接用 https://gith ...