运行终端“扫描"快速代码命令 [英] run the terminal "scan" command from swift code

查看:89
本文介绍了运行终端“扫描"快速代码命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了扫描程序以自动执行我的测试过程.我使用以下网站上的流程: http://qualitytesting.tumblr.com/post/141771752059/run-a-subset-of-xctest-tests-with-fastlanescan

i have installed scan to automate my testing process. i use the process from below website:http://qualitytesting.tumblr.com/post/141771752059/run-a-subset-of-xctest-tests-with-fastlanescan

我有两个项目,一个是ios,另一个是运行ios项目的Osx.

I have two project one is ios and another is Osx which runs the ios project.

在osx项目中,我初始化了扫描文件,并在那里添加了ios项目的方案.

In the osx project, i init the scan file and there i add the scheme of ios project.

运行

scan 

终端上的

命令,它可以成功运行ios项目.

command from terminal, it runs the ios project successfully.

但是,如果我使用以下代码:

But if i use below code:

class func shell(args: String...) -> Int32 {
    let task = NSTask()
    task.launchPath = "/usr/bin/env"
    task.arguments = args
    task.currentDirectoryPath = "/Users/username/Desktop/Xocde/mainSwiftAutomation/"
    task.launch()
    task.waitUntilExit()
    return task.terminationStatus
}

然后像这样调用函数:

classname.shell("scan")

它显示以下错误:

env: scan: No such file or directory

请帮助.

推荐答案

如果您进行更改,扫描将运行

Scan will run if you change

task.launchPath = "/usr/bin/env"

task.launchPath = "/usr/local/bin/scan"

如果您的扫描仪安装在那里.这是我机器上的问题.

if your Scan is installed there instead. This was the problem on my machine.

应用程序仍然无法找到xcpretty来生成报告,但是我的UI测试可以运行.

The application is still unable to find xcpretty to generate the report, but my UI tests do run.

如果将带有shebang的代码(#!/usr/bin/env swift )添加到常规的 run_tests.swift 文件(而不是命令行工具)中项目),那么您应该可以在命令行中运行它而不会出现问题:

If you add the code with the shebang (#!/usr/bin/env swift) to a regular run_tests.swift file (rather than a Command Line Tool project), then you should be able to run it without problems from the command line:

$ swift run_tests.swift

...正在从Swift代码运行测试,而不是通过Xcode运行测试.

...which is running the tests from Swift code but not through Xcode.

这篇关于运行终端“扫描"快速代码命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆