Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages of XCTest over SenTestingKit?

Tags:

I want to do unit testing in iOS. By default test classes are created using XCTest framework classes in Xcode 5. I have used SenTestingKit in earlier versions of iOS. What are the differences between these two frameworks? What are the advantages of XCTest framework. 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.

like image 444
sridevi Avatar asked Sep 17 '13 16:09

sridevi


People also ask

Why use XCTest?

Use the XCTest framework to write unit tests for your Xcode projects that integrate seamlessly with Xcode's testing workflow. Tests assert that certain conditions are satisfied during code execution, and record test failures (with optional messages) if those conditions aren't satisfied.

What is XCTest?

475. A testing framework that allows to create and run unit tests, performance tests, and UI tests for your Xcode project. Tests assert that certain conditions are satisfied during code execution, and record test failures if those conditions are not satisfied.

When was XCTest introduced?

XCTest was first announced at WWDC 2016, alongside the release of iOS 10. Before XCTest, automated testing on iOS was only possible using the UI Automation framework via instruments.

What is the difference between xcuitest / xctest / espresso?

XCTest / XCUITest is pure iOS and cannot help the team that needs to test both iOS and Android devices. XCUITest was built for the iOS and Xcode Developer in mind and focuses less on the QA Automation Engineer. What is Espresso? Like XCTest, Espresso is a native framework for UI testing.

Is xcuitest good for smoke and regression testing?

XCUITest is less stable and reliable when testing on real devices, making it not ideal for smoke and regression testing. XCUITest is limited in it’s support for a variety of languages.

Is xcuitest a good anti-flake tool?

XCUITest is a great “anti-flake” option when testing on emulators and/or running unit tests, but this benefit does start to dwindle when testing on real devices. XCUITest is less stable and reliable when testing on real devices, making it not ideal for smoke and regression testing.

What is xcuitest?

XCUITest is a native framework for UI testing on iOS mobile devices. Since XCUITest is baked right into Xcode IDE, it provides the fastest possible testing for iOS devices. However, there are several limitations to be aware of in addition to the several major benefits.


2 Answers

Apple's documentation is notably lacking with regards to testing. It's a shame, because spending five minutes with XCTest made me fall for it. 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)

Then, read about Bots. They're the real magic in 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. 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

All that said, I don't know SenTest well enough to compare the two. But I am learning XCTest, so here are a few thoughts on what I'm really digging about it so far.

  • 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. You can also use Companion View to see the testers from source, or the source from tester methods. Also, it will always be up to date - no waiting to fix integration with Xcode because Apple "broke" something.
  • 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.

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.
  • You are tied to Xcode a little more deeply. Not really a con for development, but scripting XCTest isn't as elegant as other options may be.
  • Continuous Integration requires 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. I am not at all bitter about this one (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.

like image 112
eddieroger Avatar answered Sep 22 '22 06:09

eddieroger


XCTest are included by default with ios7 and integrate better with the new continuous integration functionality.
https://developer.apple.com/technologies/tools/

like image 45
forbra Avatar answered Sep 18 '22 06:09

forbra