iOS Unit Testing With OCMock
Mock objects are an important driver of test driven development (TDD). They give developers the ability to craft unit tests involving complex objects without risking the possible complications inherent in instantiating those objects. They can be used to test code’s behavior when things go wrong, when infrequent things happen, or when a complex system of objects needs to be in a specific state. They are good for testing methods that return non-deterministic results (like the current time), and standing in for objects you plan to build, but haven’t built yet. In short, they’re useful, but xCode does not support them out of the box.
Apple’s xCode ships with OCUnit which is “a faithful implementation of xUnit patterns for Objective-C”[Vollmer]. Though useful for testing (it provides the various combinations of assertions covering nulls, exceptions, true, false, and equality), it lacks the capability to produce mock objects. That’s where OCMock comes in. OCMock is a library that works with Objective-c and provides methods that allow you to employ mock objects throughout your own applications. In this post, I’ll be walking through the setup of OCMock in Apple’s xCode environment and running through a few basic use cases for the OCMock library.
iOS Behind the Curve
With the recent “maps snafu” and the management shakeup at Apple, I’m sure everyone is looking out for what the next iOS move will be. I’ll tell you right now, it has to be “better than…”.
I’ll go right ahead and say it. As far as design is concerned, you can’t beat Apple. Their phones are the shiniest, nicest looking pieces of hardware, and the inclusion of a single home button IMHO is just genius. And who I ask, is the driving force behind those design decisions? Well, it’s Sir Jonathan Ive. In case you don’t know who that is, this is the guy who should’ve been CEO after Steve Jobs’ passing. He is Job’s “design soul-mate” and everyone knows Jobs was Apple’s heart and soul. So, based on that, the decision for CEO was pretty simple for me. What do you think?
Anyways, after the exit of Scott Forstall, the previous head of iOS development, Eddy Cue and Jonny Ive will be leading iOS, and lemme tell you, they’ve got their work cut out for them. While Apple’s been sitting on their laurels, Google Android and Windows Phone have put out some quality product.
iOS looks dated
iOS is a good system but compared to Android and Windows Phone, it’s starting to show its age. Android widgets are cool and they provide varied and rich functionality. I also took a look at Nokia’s Lumia 920 recently and found it to be a very slick and fast phone, and the Windows OS looks cool and is very user friendly.
What’s in the future for iOS?
Widgets? Different layout? Unlikely. But whatever they end up doing has to be better than the competition, and right now, that’s no short order. Then again, they have Jonny Ive, and that guy does not disappoint. Few people remember nowadays that in the mid 90′s Apple as a whole, was behind the curve. Job’s return, and his passion for Apple enabled the company for change and growth. Product design became it’s hallmark, designs that are currently driven by Ive. Now, let’s see what he comes up with in the software space. I for one, can’t wait!
What Would Steve Do?
I purchased the original iPhone in July of 2007, just after it’s release. My favorite core applications have always been Maps, Safari and Mail. Oh, yeah, I also like the Phone App. I was so impressed with the iPhone I purchased some additional AAPL stock.
Owning the stock I have followed Apple’s progress over the years. I was saddened when I learned of Steve Jobs’s health turning for the worse and his subsequent death at age 56 on October 5, 2011. I wondered the same thing I’m sure many others did, what will happen to Apple?
The “Beautifully designed from the ground up,” Maps in iOS 6, one of the ‘new’ features available on the iPhone 5 was the first major misstep since Jobs stepped down as CEO. Directions are wrong and key features such a public transit are missing. And it’s not like they didn’t know there were problems.
How do you like them Apples?
In a little less than a week, Apple will unveil the latest generation of the iPhone. I’m going to go ahead and predict that Apple-fans will think it’s the greatest thing ever and find themselves in a spot where they suddenly need one. Most non-Apple fans will probably deride it for not being fast enough, big enough, small enough, or just plain too “Apple.”
In any event, watching Apple prime the PR wires and get “buzz” serves as a nice reminder that technical products need to continually advance and evolve to remain relevant. There’s always some other company out there coming up with a bigger/smaller/faster/better, version of your product. If you’re not constantly evolving, you’re falling behind.
Flashback!
Something tells me that the fine folks in Cupertino will not be enjoying their Spring break. Yep – Apple has a full-scale trojan virus/malware thingy on their hands, and it appears to be exploiting Macs either exclusively, or more likely, as a matter of sheer convenience.
The “Flashback Virus” takes advantage of an older Java flaw that Apple didn’t release a patch for right away. Once on your system, it goes looking for info (passwords, etc) and then reports back to a central server. The infection percentage is something like 98% Mac OS, 2% “other”. For much more detail, go to: http://www.macworld.com/article/1166254/what_you_need_to_know_about_the_flashback_trojan.html
The Audacity of Nope
The technology industry and indeed the world lost a titan of the modern technology pantheon yesterday. Steve Jobs was a pioneer and an innovator and a progressive thought leader, but what may have been greatest about Jobs in my view was his audacious, fervent and oftentimes smug ability to say No.
Read more >>
Recent Posts
- iOS Unit Testing With OCMock
- Why Stakeholders Need To Be Involved In Scrum
- NuGet Config File Transformation Causes Duplicate Entries On Update
- Load Testing with Locust on Windows
- Writing A Custom LINQ Provider With Re-linq
- AutoMapper Profile Organization
- Rails 3.2: A Nested-Form Demo Part 4: Switch to Targeting Computer!
- SharpRepository: Configuration
- Rails 3.2: A Nested-Form Demo, Part 3: We’re Starting Our Attack Run!
- Rails 3.2: A Nested-Form Demo, Part 2: Accelerate to Attack Speed!
- Rails 3.2: A Nested-Form Demo, Part 1: All Wings Report In!
- iOS Behind the Curve
- Distributed Transaction Coordinators, Port 135, and Firewalls – Oh My!
- SharpRepository: Getting Started
- Find Performance Problems Using JMeter, MySQL and Xdebug/Webgrind
- Taming Hot Key Context Shifting When Running A Windows VM In Virtualbox On OSX
- Integrating Twitter’s Bootstrap Into Your Project
- Mobile payments, tags and more using NFC
- Stress Pig
- Dear Client Services, What Works?
- What Would Steve Do?
- Still Using Fiddler to Test & Debug Your REST Services?
- Write-through and Generational Caching Make a Great Team
- Thinking Recursively
- Development Incentives, What’s the Payoff?
- How do you like them Apples?
- “Optional” Software Development Practices Series — Code Review
- Adding Images to Select Lists in MVC3
- “Optional” Software Development Practices Series
- You Get What You Pay For…
- Outsourcing Safety Tips
- Facebook IPO
- The Ballad of Tim Toady
- The Little Schemer
- Newsflash: Mom leaves tech job at 5p.m.
- Flashback!
- I <negative_emotion> Windows 8!
- Prefix vs. Postfix Increment and Decrement Operators in C++
- Corporate videos: viral boon or epic fail?
- Recruitin’ Time!
- Reference vs. pointer parameters in C++
- The IE8 "hover" Bug: The Most Awesome IE Bug Ever?
- When is perfect perfect enough?
- SOPA/PIPA: Anti-Censorship Protest or Techies Revenge?
- A Decade of Fairway
- Handling Session Timeout Gracefully
- Generating Software Diagrams
- The Audacity of Nope
- The Origins of Culture
- Scrum Overview in Prezi – not another boring slideshow
- Numbers don’t lie: LinkedIn Statistics
- What is your favorite software development tool?
- Best Practices for Selecting Onshore, Nearshore or Offshore Information Technology Outsourcing (ITO) Providers
- Sign of the Times
- Advantages and Risks of Offshoring, Nearshoring or Onshoring
- Does Outsourcing Mean Offshoring?
- Too little, too late?
- New Favorite Lunch Spot
- Why should I care about functions as first-class citizens?
- PHP Remote Debugging with XDebug and NetBeans
- Installing SubText with Web PI
- ROI Primer
- Learn Domain-Driven Design
- Learn Behavior-Driven Development
- Mario Kart Tournament
- F# in 90 Seconds
- Website Vulnerabilities
- Scrum Overview
- Language Club
- Top 12 Favorite Podcasts Ever…
- Fairway Dart Tournament
- Learn Lean Software Development and Kanban Systems
- Android – Eclipse Quick Start
- Learn Functional Programming
- Backup & Restore Strategy
- Smartphone Screens – Another Wireless Variable
- Wireless Application Market
- Head First AOP





