Unit Testing
Unit tests are clearly defined specific cases which test the implementation and function of code. Apple defines unit testing as "...a way to ensure that the code you write adheres to design specifications and that it keeps adhering to those specifications as you modify it. Unit-testing helps you write robust and secure apps. The essential component of unit-testing is a test case, which tests your code at the lowest testable level, or unit."
When your team commits to a well-defined testing strategy, quality assurance and code maintenance become an integral part of your software development process. Unit tests eliminate risk and give you confidence that your changes will not break existing functionality, especially when you're working with many consumers of your code.
Unit testing can be a sensitive subject for some developers because it's not absolutely necessary. Clients and corporations may view unit testing as unnecessary expenditure. The notion that unit testing is unwarranted is a common fallacy among stakeholders.
In the short term it's hard to justify the value of unit tests, especially to a client. But it's your job to make them understand that unit testing is an investment. You're building a solid foundation as well as practicing good coding standards that will produce a top-notch product. Unit testing emphasizes code quality above all else.
All projects at some point experience a lack of resources (time, money, etc). Insufficient resources aren't a proper excuse to skimp on unit testing. Sure, unit testing isn't required but neither is refactoring code; code is refactored to improve upon what is already exists. Just because something works doesn't excuse you from refactoring. Developers should ask themselves, *what will make the biggest impact for the least amount of effort?*
The same principle can be applied to unit testing. Developers should find a balance when unit testing. Full code coverage is unnecessary so it's important to know what should be tested. Look for areas in your code that are important, high risk, or have had to be fixed in the past.
With the latest version of Xcode 5, there are some great new tools available for developers to unit test their apps. XCTest framework is Apple's new testing harness that's based OCUnit.
Xcode and Xcode server introduce bots that can build, analyze, test, and report the status of an Xcode project on every commit to your repository. See my post on Git for more on source control.
I applaud Apple's attempt to make unit testing interesting again. I think they've done it. And at the very least, they've given developers something to experiment with. They obviously understand the value of unit testing.














