简体   繁体   English

XCTest优于SenTestingKit有什么优势?

[英]What are the advantages of XCTest over SenTestingKit?

I want to do unit testing in iOS. 我想在iOS中进行单元测试。 By default test classes are created using XCTest framework classes in Xcode 5. I have used SenTestingKit in earlier versions of iOS. 默认情况下,测试类是使用Xcode 5中的XCTest框架类创建的。我在早期版本的iOS中使用过SenTestingKit。 What are the differences between these two frameworks? 这两个框架之间有什么区别? What are the advantages of XCTest framework. XCTest框架有哪些优点。 I googled for related documentation but I did not find any. 我搜索相关文档,但我没有找到任何。 Only thing I found is the interface classes to use inside the kit. 我发现的只是套件中使用的接口类。 Can anyone point me to the related resources. 谁能指出我相关的资源。

Apple's documentation is notably lacking with regards to testing. Apple的文档在测试方面尤其缺乏。 It's a shame, because spending five minutes with XCTest made me fall for it. 这是一种耻辱,因为用XCTest花了五分钟让我感到沮丧。 So, here are some docs that you may find useful. 所以,这里有一些你可能会觉得有用的文档。

First, stop and watch the WWDC video about testing: https://developer.apple.com/wwdc/videos/?include=409#409 (must be a registered developer) 首先,停下来观看有关测试的WWDC视频: https//developer.apple.com/wwdc/videos/? include = 409 #409(必须是注册开发者)

Then, read about Bots. 然后,阅读Bots。 They're the real magic in XCTest. 它们是XCTest中真正的魔力。 I'm currently setting up an environment of a Mac Mini running Mavericks Server connected to a small array of iPod Touches, iPhones and iPads that will simultaneously run my unit tests and report back. 我目前正在建立一个运行Mavericks服务器的Mac Mini环境,该服务器连接到一小部分iPod Touch,iPhone和iPad,它们将同时运行我的单元测试并报告回来。 It's damn near magic. 它真是太神奇了。

https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/000-About_Continuous_Integration/about_continuous_integration.html#//apple_ref/doc/uid/TP40013292 https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/000-About_Continuous_Integration/about_continuous_integration.html#//apple_ref/doc/uid/TP40013292

All that said, I don't know SenTest well enough to compare the two. 所有这一切,我不太了解SenTest足以比较两者。 But I am learning XCTest, so here are a few thoughts on what I'm really digging about it so far. 但是我正在学习XCTest,所以这里有一些关于我到目前为止正在挖掘它的想法。

  • It's already there. 它已经存在了。 There's nothing to download, and you can make your test class objects at the same time as you make that which you wish to test. 没有什么可下载的,您可以在制作要测试的对象的同时制作测试类对象。 Rad. 拉德。
  • Because it's integrated so deeply with Xcode, you can see test coverage in the gutter. 因为它与Xcode的集成非常深入,所以您可以在排水沟中看到测试覆盖率。 You can also use Companion View to see the testers from source, or the source from tester methods. 您还可以使用Companion View从源查看测试器,或从测试器方法查看源。 Also, it will always be up to date - no waiting to fix integration with Xcode because Apple "broke" something. 此外,它将永远是最新的 - 没有等待修复与Xcode的集成,因为苹果“打破”了一些东西。
  • Continuous Integration. 持续集成。 The bots are just magical, and they're so easy. 机器人只是神奇的,它们很容易。 You also get Git hosting, which is a small fringe perk, but more so if you prefer your Git internally hosted but don't want to pay for GitHub Enterprise. 你也得到Git托管,这是一个小的边缘特权,但如果你更喜欢你的Git内部托管但不想支付GitHub Enterprise更多。

And, a few cons for measure: 并且,一些衡量标准:

  • Lack of Documentation. 缺乏文档。 Asking me to read the headers for a list of assertions is a ballsy move. 要求我阅读断言列表的标题是一个很好的举动。 I have no doubt Apple will fix this soon, but not soon enough. 我毫不怀疑Apple很快会解决这个问题,但不会很快。
  • You are tied to Xcode a little more deeply. 你更深入地与Xcode联系在一起。 Not really a con for development, but scripting XCTest isn't as elegant as other options may be. 并不是真正的开发,但脚本XCTest并不像其他选项那样优雅。
  • Continuous Integration requires OS X Server. 持续集成需要OS X Server。 It can be on the same machine if you really want, but it's $20 to buy, even if you owned Mountain Lion Server. 如果你真的想要,它可以在同一台机器上,但即使你拥有Mountain Lion Server,也可以购买20美元。 I am not at all bitter about this one (ha). 我对这个(ha)一点都不苦。

My two cents. 我的两分钱。 Hope it helps. 希望能帮助到你。 I'd really recommend watching that video I linked to - they do live test creation and make a really compelling case for unit testing in general, regardless of if you use XCTest. 我真的建议观看我链接的视频 - 他们会进行实时测试创建,并为一般的单元测试制作一个非常引人注目的案例,无论你是否使用XCTest。

XCTest are included by default with ios7 and integrate better with the new continuous integration functionality. XCTest默认包含在ios7中,并且与新的持续集成功能更好地集成。
https://developer.apple.com/technologies/tools/ https://developer.apple.com/technologies/tools/

It seems the advantages are presently few, but that will hopefully change over time, so starting a community wiki to document some: 看来优势目前很少,但随着时间的推移,这将有希望改变,所以启动社区维基来记录一些:

  • The XCTAssert… family of macros can handle you leaving out the format parameter (used for commenting why a test should pass) entirely. XCTAssert…系列宏可以处理你XCTAssert… format参数(用于评论测试应该通过的原因)。 This is handy for keeping simple tests (where it's obvious from the test itself what it's doing) clean in the editor. 这对于在编辑器中保持简单测试(从测试本身显而易见的是它在做什么)清理是很方便的。 STAssert… required us to make the format parameter nil or some such instead. STAssert…要求我们将format参数设置为nil或其他一些。
  • There's a generic XCTAssert() macro, which feels neater than bodging some types of check into STAssertTrue . 有一个通用的XCTAssert()宏,它比把一些类型的检查放入STAssertTrue感觉更整洁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS:xcode 5,将项目从xctest迁移到senTestingKit - iOS: xcode 5, migrate project from xctest to senTestingKit 为什么XCode 6测试导航器不使用XCTest但使用SenTestingKit? - Why the XCode 6 test Navigator does not use XCTest but SenTestingKit? 在iOS开发中LLDB优于GDB有什么优势? - What are the advantages of LLDB over GDB in iOS development? SnapKit在Interface Builder中使用autolayout有什么优势? - What advantages does SnapKit have over using autolayout in Interface Builder? iOS6 UDID-identifierForVendor相对于identifierForAdvertising有什么优势? - iOS6 UDID - What advantages does identifierForVendor have over identifierForAdvertising? Bing地图比iOS上的Map Kit有什么优缺点 - What are the advantages / disadvantages of Bing maps over Map Kit on iOS iOS 5.0故事板比传统UI布局有什么优势? - What are the advantages of iOS 5.0 storyboarding over traditional UI layout? 激活离线模式时Core Data优于Firebase实时数据库有哪些优势? - What are the advantages of Core Data over Firebase realtime database when offline mode is activated? 使用预编译静态库而不是直接包含它的源代码有什么好处? - What are the advantages of using precompiled static library over directly including it's source code? 在编译iPhone应用程序时,armv7优于armv6有什么优势? - What are the advantages of armv7 over armv6 when compiling iPhone apps?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM