zoukankan      html  css  js  c++  java
  • 用GHUnit运行ASIHttpResquest的测试案例

    下载ASIHttpResquest后,打开iPhone工程,你会发现在Tests组下有许多.m/.h文件,这是作者用GHUnit框架编写的测试案例。而且工程中也建立了一个target,名为Tests,显然是为了编译运行测试案例而配置的。但你却无法编译这个target,因为GHUnitIOS.framework不存在。要想运行这些测试案例,我们还必须做一些额外的工作(以Xcode3.23为例)。

    首先,下载GHUnit。该项目地址是:

    https://github.com/gabriel/gh-unit#readme

    下载,解压后得到GHUnitIOS.framework。把它复制到ASIHttpRequest的External/GHUnit目录下。

    确认在Tests的linked Binary Libraries下有以下内容:

    GHUnitIOS.framework

    CoreGraphics.framework

    Foundation.framework

    UIKit.framework

    确认Tests的Build设置中,Framework Search Paths设置为GHUnitIOS.framework目录。

    确认Tests的Build设置中,Other Linker Flag设置中包含-ObjC和-all_load。

    把Tests-info.plist中的Main nib file base name一行删除。

    确认项目中已加入GHUnitIOSTestMain.m文件,并已包含在Tests中。该文件下载地址:

    http://github.com/gabriel/gh-unit/blob/master/Project-iOS/GHUnitIOSTestMain.m

    确认所编写的测试案例中已包含:<GHUnit/GHUnit.h>

    选择Targets下的Tests,右键->Build “Tests”。在左上角的Build Configure中选择Active Target为Tests,然后点“Buildand Run”,程序运行效果如下:

    点击打开链接

    程序列出了所有测试案例,点击右上角的Run按钮,将运行所有测试案例。如果选择一个测试案例,比如ClientCertificateTests类的testClientCertificate方法,在点击Re-run按钮,则会单独运行该案例。在控制台窗口可以查看该案例是否通过测试:

    2011-09-15 11:40:16.236 Tests[996:207]ClientCertificateTests/testClientCertificate ✔ 3.09s

    右侧的勾号表明该测试通过,并列出测试所用时间。



  • 相关阅读:
    instance
    iptables
    centos系统准备
    Leecode no.236 二叉树的最近公共祖先
    Leecode no.235 二叉搜索树的最近公共祖先
    leecode no.98 验证二叉搜索树
    leecode no.109 有序链表转换二叉搜索树
    leecode no.113 路径总和 II
    Leecode no.112 路径总和
    Leecode no.111 二叉树的最小深度
  • 原文地址:https://www.cnblogs.com/encounter/p/2188454.html
Copyright © 2011-2022 走看看