gpt4 book ai didi

ios - 使用 iOS 实现单元测试

转载 作者:IT王子 更新时间:2023-10-29 07:42:55 29 4
gpt4 key购买 nike

我关注了this tutorial当我遇到问题时在我的应用程序上设置单元测试。

在该教程的第 8 点,它显示了这张图片,这是我在构建时应该期待的:alt text http://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iphone_development/art/logic_test_failure_text_editor.jpg

然而,这不是我在构建时得到的。我收到此错误消息:Command/bin/sh failed with exit code 1 以及单元测试创​​建的错误消息。然后,当我展开第一个错误时,我得到了这个:

PhaseScriptExecution "Run Script" "build/3D Pool.build/Debug-iphonesimulator/LogicTests.build/Script-1A6BA6AE10F28F40008AC2A8.sh"
cd "/Users/james/Desktop/FYP/3D Pool"
setenv ACTION build
setenv ALTERNATE_GROUP staff
...
setenv XCODE_VERSION_MAJOR 0300
setenv XCODE_VERSION_MINOR 0320
setenv YACC /Developer/usr/bin/yacc
/bin/sh -c "\"/Users/james/Desktop/FYP/3D Pool/build/3D Pool.build/Debug-iphonesimulator/LogicTests.build/Script-1A6BA6AE10F28F40008AC2A8.sh\""

/Developer/Tools/RunPlatformUnitTests.include:412: note: Started tests for architectures 'i386'
/Developer/Tools/RunPlatformUnitTests.include:419: note: Running tests for architecture 'i386' (GC OFF)
objc[12589]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
Test Suite '/Users/james/Desktop/FYP/3D Pool/build/Debug-iphonesimulator/LogicTests.octest(Tests)' started at 2010-01-04 21:05:06 +0000
Test Suite 'LogicTests' started at 2010-01-04 21:05:06 +0000
Test Case '-[LogicTests testFail]' started.
/Users/james/Desktop/FYP/3D Pool/LogicTests.m:17: error: -[LogicTests testFail] : Must fail to succeed.
Test Case '-[LogicTests testFail]' failed (0.000 seconds).
Test Suite 'LogicTests' finished at 2010-01-04 21:05:06 +0000.
Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.000) seconds

Test Suite '/Users/james/Desktop/FYP/3D Pool/build/Debug-iphonesimulator/LogicTests.octest(Tests)' finished at 2010-01-04 21:05:06 +0000.
Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.002) seconds

/Developer/Tools/RunPlatformUnitTests.include:448: error: Failed tests for architecture 'i386' (GC OFF)
/Developer/Tools/RunPlatformUnitTests.include:462: note: Completed tests for architectures 'i386'
Command /bin/sh failed with exit code 1

现在这很奇怪,因为它正在运行测试(并且成功,因为您可以看到我的 STFail 触发),因为如果我添加一个通过的不同测试,我不会收到任何错误,所以测试工作正常。但为什么这个额外的构建会失败?

可能还需要注意的是,在下载应该开箱即用的解决方案/模板时,我遇到了同样的错误。我猜我在这里设置了一些错误,但我只是 100% 正确地按照教程进行操作!

编辑:根据 this blog , this post和其他一些网站,我不是唯一遇到这个问题的人。自 xCode 3.2 发布以来一直是这样,假设苹果开发中心文档和教程等也是 pre-3.2。

然而,有些人说这是一个已知问题,而其他人似乎认为这是故意的。我个人想要扩展控制台和代码消息,我当然不喜欢“Command/bin/sh ...”错误,并且真的认为他们会记录这样的更新。希望它能尽快修复。

更新:这里确认它自 xCode 3.2.1 发布以来发生了一些变化。

这张图片: alt text http://ing0.co.uk/info/pics/unittest-xcode-3.2.1.png来 self 使用 3.2.1 的测试版本。这个来自旧版本(3.1.4): alt text http://ing0.co.uk/info/pics/unittest-xcode-3.1.4.png . (两者的项目都没有改变)。

最佳答案

双击“目标”/“您的脚本目标名称”下的“运行脚本”,然后键入

# Run the unit tests in this test bundle. "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests" 1> /tmp/RunUnitTests.out

基本上你需要追加

1> /tmp/RunUnitTests.out

已经存在的

关于ios - 使用 iOS 实现单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2002330/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com