Search code examples
iosobjective-cunit-testingwhite-box

Unit test private class in Objective-C


How do you unit test a private class in Objective-C? Is it possible when both the @interface and the @implementation of the class are included in a .m implementation file?

Refactoring the interface of the private class into its own header is not allowed by the restrictions of the project.

This is a whole private class I would like to test, not a private method of a public class.


Solution

  • Apparently, duplicating the private interface in the test file is enough. Damn, Objective-C is dangerous!