如何在 Xcode 8 上可靠地安装和设置快速测试框架? [英] How to reliably install and setup Quick test framework on Xcode 8?

查看:34
本文介绍了如何在 Xcode 8 上可靠地安装和设置快速测试框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:
在研究这个答案时,我注意到正确设置快速测试框架并非易事在 Xcode 上正确.就我而言,尝试了 3-4 次失败后才最终获得了一个工作版本.而且,我不确定我之前的尝试哪里错了.或者更重要的是,为什么该线程中的提问者每次都可以重复运行.然后他也花了几次尝试终于有了一个可行的方法.

Background:
While working on this answer I noticed that it's not so trivial to properly set up Quick test framework on Xcode properly. In my case, it took 3-4 failed attempts to finally have a working version. And still, I'm not sure where my previous attempts were wrong. Or more importantly why the questioner in that thread could have duplicate run each time. Then it also took him several attempts to finally have a working one.

问题:
我在问你们是否有一种可靠的方法来使用 Cocoa pods(或 Carthage 或 Git 子模块)在 Xcode 上设置 Quick Framework,直到运行一个您愿意分享的正常工作的 Quick 测试用例.

Question:
I am asking if any of you have a reliable way to set up Quick Framework on Xcode using Cocoa pods (or Carthage or Git Submodule), up to running a properly working Quick test case, that you're willing to share.

我以前是怎么做的:
下面是我如何在 Xcode 上创建我的工作 Quick 框架:
1. 我按照 RayWenderlich 站点中 XCTest 文章中的步骤进行操作 设置 XCTest 环境.
2. 然后我按照 安装 Quick 添加 Cocoa Pods
3. 然后按照设置你的Xcode
4. 然后我在剩下的所有过程中进行黑客攻击和即兴创作,在谷歌上搜索我遇到的每个问题,尝试这个和那个直到它起作用.
(其中包括在目标的构建阶段添加快速框架以链接二进制文件)

How I did it before:
Here is how I created my working Quick framework on Xcode:
1. I follow the step in XCTest article in RayWenderlich site to set up XCTest environment.
2. Then I add the Cocoa Pods as per installing Quick
3. Then follow instruction in Setting up your Xcode
4. Then I hacked and improvise all the rest of the way, googling for each issue I encounter after that, try this and that until it works.
(Among those steps include add Quick framework to link binary in build phase of my target)

我并不自豪能分享我上面的步骤,但我现在没有更好的方法.我希望通过问这个问题找到更好的方法.可能问的太多了.

I'm not proud to share my steps above, but I don't have a better way for now. I hope to find a better way by asking this question. It might be too much to ask.

我的 Podfile :

target 'PlayQuick' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for PlayQuick

target 'PlayQuickTests' do
    inherit! :search_paths
    # Pods for testing
    pod 'Quick'
    pod 'Nimble' 
end

end

推荐答案

Git 子模块方式 是实现这一目标的最精简和最简单的方式.

Git submodule way is the most lean and simple way to achieve that.

按照以下步骤从零开始:

1.a.选中 Include Unit Tests 创建 Xcode 项目.

1.a. Create Xcode project with Include Unit Tests checked.

1.b.或者,您可以在现有项目上创建单元测试目标.

1.b. Alternatively, you could create unit test target on existing project.

  • 打开测试导航器.
  • 点击左下角的 + 按钮,然后从菜单中选择 New Unit Test Target...:


2.关闭(1)
中的Xcode工程
3. 创建新的 Xcode 工作区.文件 -> 新建 -> 工作区.

4. 打开终端/Bash Shell/Cmd.exe

5. 为 GitHubProjectClones 创建一个新的子目录.


2. Close the Xcode project in (1)

3. Create new Xcode workspace. File -> New -> Workspace.

4. Open Terminal / Bash Shell / Cmd.exe

5. Create a new sub directory for GitHubProjectClones.

  • 例如:$HOME/Developer/GitHubProjectClones


6. cd到(5)中的子目录:


6. cd to sub directory in (5):

  • mkdir 供应商
  • git 初始化


7.按照Git Submodule section

  • git 子模块添加 git@github.com:Quick/Quick.git Vendor/Quick
  • git 子模块添加 git@github.com:Quick/Nimble.git Vendor/Nimble
  • git submodule update --init --recursive


8. 按照Git Submodule section中的步骤two进行操作.

  • 打开工作区返回 Xcode:
    • 确保选择了项目导航器
      • 文件 -> 将文件添加到:
        • 选择在第 7 步中创建的 Quick 文件夹.
        • 选择在第 7 步中创建的 Nimble 文件夹.
        • 在步骤 1 中选择您的 Xcode 项目.


        9. 按照 Git Submodule section 中的步骤 three 链接 Quick.frameworkNimble.framework 在您的测试目标的将二进制文件与库链接 构建阶段.

        10. 您应该能够按照快速文档


        9. Follow step three in Git Submodule section to link Quick.framework and Nimble.framework during your test target's Link Binary with Library build phase.

        10. You should be able to follow along the examples in Quick Documentation

        这篇关于如何在 Xcode 8 上可靠地安装和设置快速测试框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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