Skip to content
allending edited this page Nov 30, 2011 · 17 revisions

Q: How do I use Kiwi with UIKit classes?

A: Xcode comes built in with support for 2 types of test targets, Logic Tests and Application Tests. The main difference between them is that an Application test target has a UIApplication instance and main run loop associated with it (OK, not entirely accurate but this is an easy way to think about it).

Most of UIKit requires the presence of a UIApplication to behave properly. Specs that perform operations on UIKit classes (e.g. UILabels) will probably crash weirdly if they are run under anything other than an Application Test. To learn more about how to set up an Application Test target, check out the official Apple docs.

Q: How do I test my private/internal methods?

A: This is less of a Kiwi question, and goes more towards testing methodology. Instead of testing internal methods that are specific to a particular class' implementation, we recommend evaluating the structure of the class to see if the functionality that needs to be tested can be extracted into a public class of its own. Testing internal methods is inherently brittle because internal implementation details are by nature the part of a class that changes the most. Your testing experience will be much more fun when it goes through a more stable public interface for the majority of classes. Discussion that brought about this question.