Currently I’m working a couple of frameworks, the first is written in Objective-C so testing of the framework is pretty easy, add OCMockito and OCHamcrest and done, right? Enter the second framework, since this framework is written in Swift we do encounter a problem: How to mock ins Swift.
At first the solution was not so clear, first instinct is to add a test class and set the language of the test class Swift. That gives you the problem of not being able to test using the OCMockito, for now I have not found a similar framework that hels me mock objects for Swift.
On the way back home, it hit me: “If we can use Swift code in a Objective-C project and vice-versa, why not also for writing the tests?”
And it works. Now I write the implementation in Swift and my test classes in Objective-C, and am able to use mocked objects to test the swift implementation.