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

简单封装下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. Mac下Mysql配置

    安装 http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.6/mysql-5.6.41-macos10.13-x86_ ...

  2. 【原】命令行增删改查阿里云 DNS

    命令行解析阿里云 DNS 项目地址:https://github.com/liyongjian5179/alidns 首先需要获取阿里云账号账号的AccessKeyID及AccessKeySecret ...

  3. Codeforces I. Producing Snow(优先队列)

    题目描述: C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input stand ...

  4. Java精通并发-Lock与synchronized关键字在底层的区别及实例分析

    在上两次中已经将Lock这个接口的整个官方说明进行了阅读,这次来了解一下它的一个非常重要的实现类: 啥叫“可重入”呢?其实是指一个线程已经拿到了锁,然后该线程还能再次获取这把锁,接下来在了解它之前先用 ...

  5. httprunner学习3-extract提取token值参数关联(上个接口返回的token,传给下个接口请求参数)

    前言 如何将上个接口的返回token,传给下个接口当做请求参数?这是最常见的一个问题了. 解决这个问题其实很简单,我们只需取出token值,设置为一个中间变量a,下个接口传这个变量a就可以了.那么接下 ...

  6. python 实现 DES CBC模式加解密

    # -*- coding=utf-8-*- from Crypto.Cipher import DES import base64 """ des cbc加密算法 pad ...

  7. which had no Root Element. This likely means the XML is malformed or missing

    今天按照古月老师的步骤,想在RViz中配置插件. 按步骤做下来后,一运行,出现如下错误: [E[ERROR] [1523370744.057263390]: Skipping XML Document ...

  8. xargs的用法

    处理带有空格的文件名 #我们创建了3个日志文件, 且故意让文件名称中都含有空格 [roc@roclinux ~]$ ;i<;i++)); do touch "test ${i}.log ...

  9. MapReduce的核心运行机制

    MapReduce的核心运行机制概述: 一个完整的 MapReduce 程序在分布式运行时有两类实例进程: 1.MRAppMaster:负责整个程序的过程调度及状态协调 2.Yarnchild:负责 ...

  10. 清华大学&中国人工智能学会:2019人工智能发展报告

    2019年11月30日,2019中国人工智能产业年会重磅发布<2019人工智能发展报告>(Report of Artificial Intelligence Development 201 ...