在Instruments中运行SenTestingKit单元测试

编程入门 行业动态 更新时间:2024-10-27 08:29:45
本文介绍了在Instruments中运行SenTestingKit单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发数据库访问库,并尝试使用已编写的单元测试检查内存泄漏.

I'm developing a database-access library and I'm trying to check for memory leaks using already-written unit tests.

这些是基于SenTestingKit的逻辑测试,在Xcode 4.2中进行了常规设置.我可以使用Cmd-U很好地运行它们,但是看不到从Instruments启动它们或调用Instruments检查它们的方法.

These are logic tests based on SenTestingKit, set up the normal way in Xcode 4.2. I can run them fine using Cmd-U but don't see a way to start them from Instruments, or to invoke Instruments to examine them.

我该如何进行这项工作?我需要编写新案例并将其构建到应用程序中吗?

How can I make this work? Do I need to write new cases and build them into an application?

(这个问题与泄漏检查单元测试有关,但是我想是SenTestingKit之前的版本.)

(This question is about leak-checking unit tests but I think is pre-SenTestingKit.)

推荐答案

此答案以SenTest for OS X开头.如果您担心在乐器下使用SenTest for iOS,请跳至下一部分.

This answer begins with SenTest for OS X. If you are concerned with using SenTest for iOS under instruments, skip to the next section.

我意识到这有点晚了,但是我今天需要在逻辑测试中运行仪器,并使它在我的环境中工作,所以我做了以下事情:

I realize this is a bit late, but I needed to run instruments on a logic test today and got it working for my environment, so here's what I did:

  • 运行Instruments时,创建一个新文档.
  • 从目标"下拉列表中选择目标"
  • 选中右下角的遍历包"选项,以允许您深入研究Xcode包
  • 导航到/Applications/Xcode并在/Applications/Xcode.app/Contents/Developer/Tools/中找到otest二进制文件并选择它
  • 添加值为YES的OBCJ_DISABLE_GC作为环境变量(如果正在运行GC,则不要这样做)
  • 添加DYLD_FRAMEWORK_PATH并指向包含.octest软件包的目录
  • 添加具有与DYLD_FRAMEWORK_PATH相同值的DYLD_LIBRARY_PATH
  • 将工作目录"设置为.xcodeproj所在的目录
  • 对于参数,请使用-SenTest Self以及.octest软件包的完整路径
  • With Instruments running, create a new document.
  • Choose Target from the Target drop down in the document
  • Check the "Traverse Packages" option in the lower-right to allow you to dig inside of the Xcode package
  • Navigate into /Applications/Xcode and find the otest binary inside of /Applications/Xcode.app/Contents/Developer/Tools/ and select it
  • Add OBCJ_DISABLE_GC with a value of YES as an environment variable (don't do this if you're running GC)
  • Add DYLD_FRAMEWORK_PATH and point at the directory containing of your .octest package
  • Add DYLD_LIBRARY_PATH with the same value as DYLD_FRAMEWORK_PATH
  • Set your Working Directory to be the directory where your .xcodeproj lives
  • For arguments, use -SenTest Self and the full path to your .octest package
  • 某些环境变量和您的工作目录可能不是必需的,具体取决于您是否需要加载其他框架以及代码目录中是否有需要读取的测试文件.因此,如果不适用于您,则可以忽略这些步骤.

    Some of the environment variables and your working directory may not be essential depending on whether you need additional frameworks to load and whether you have test files in your code directory that require reading. So, you may omit those steps if they don't apply to you.

    完成后,您将可以保存文档并将其用于运行测试.

    Once you're done, you'll be able to Save the document and use it to run the tests.

    在OP明确了要求之后,我开始使用一个基于iOS模拟器的项目来验证其基本说明.

    After the OP clarified the requirements, I went about verifying the basic instructions for this with an iOS-simulator-based project.

    对于iOS,由于您正在调试其他可执行文件,因此需要不同的配置,并且将需要不同的库.因此,DYLD_FRAMEWORK_PATH将同时包含.octest软件包目录的路径和Simulator框架的路径.后者将是这样的: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/Developer/Library/Frameworks 取决于您使用的是哪个版本的模拟器,我们在下面将其称为SDKPATH

    For iOS, you need a somewhat different configuration, owing to the fact that you're debugging a different executable, and you will need different libraries. So, the DYLD_FRAMEWORK_PATH will include both the path to your .octest package's directory, and that of the Simulator's Frameworks. The latter will be something like this: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/Developer/Library/Frameworks depending on which version of the simulator you are using and we'll refer to it below as SDKPATH

  • 运行Instruments时,创建一个新文档.
  • 从目标"下拉列表中选择目标"
  • 选中右下角的遍历包"选项,以允许您深入研究Xcode包
  • 导航到/Applications/Xcode并在/Applications/Xcode/Developer/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/Developer/usr/bin/中找到otest二进制文件并将其选中
  • 添加DYLD_LIBRARY_PATH并指向包含.octest软件包的目录
  • 添加仅指向SDKPATH的DYLD_ROOT_PATH(上方)
  • 使用SDKPATH添加IPHONE_SIMULATOR_ROOT(上方)
  • 添加DYLD_FRAMEWORK_PATH并指向包含.octest软件包和SDKPATH的目录(在上方),并在路径列表中用冒号(:)分隔它们
  • 在您的iPhone模拟器家中添加CFFIXED_USER_HOME(~/Library/Application Support/iPhone Simulator,尽管我在将它放到这里之前对其进行了扩展,因为我不确定〜会被解释)
  • 将工作目录"设置为.xcodeproj所在的目录
  • 对于参数,请使用-SenTest Self以及.octest软件包的完整路径
  • With Instruments running, create a new document.
  • Choose Target from the Target drop down in the document
  • Check the "Traverse Packages" option in the lower-right to allow you to dig inside of the Xcode package
  • Navigate into /Applications/Xcode and find the otest binary inside of /Applications/Xcode/Developer/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/Developer/usr/bin/ and select it
  • Add DYLD_LIBRARY_PATH and point at the directory containing of your .octest package
  • Add DYLD_ROOT_PATH pointed just at the SDKPATH (above)
  • Add IPHONE_SIMULATOR_ROOT with SDKPATH (above)
  • Add DYLD_FRAMEWORK_PATH and point at the directory containing of your .octest package and the SDKPATH (above), separating them by a colon (:) in the path list
  • Add CFFIXED_USER_HOME with your iPhone simulator home (~/Library/Application Support/iPhone Simulator although I've expanded it before putting it here, as I'm not sure the ~ gets interpreted)
  • Set your Working Directory to be the directory where your .xcodeproj lives
  • For arguments, use -SenTest Self and the full path to your .octest package
  • 更多推荐

    在Instruments中运行SenTestingKit单元测试

    本文发布于:2023-11-24 05:05:00,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1624067.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:单元测试   Instruments   SenTestingKit

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!