MockingKit - write interactive mocks for unit tests and to fake functionality

Hi,

I hope that this is not too off-topic for this forum. In that case, feel free to remove this topic and its tags.

When I joined the iOS community in 2011, I came from .NET, where unit testing, tdd, mocking etc. were frequently discussed on conferences, at meetups etc. I found that these topics were seldom discussed in the iOS community, though, and that developers were more focused on the end user experience than discussing code quality, craftsmanship and testing. Mocking were most used to describe mocking network requests, not mock/record/inspect functionality when writing unit tests.

Much has happened since then. Apple have kept on improving XCTests and libraries like Quick and Nimble make it even easier to write tests. Swift has come along as well, and with it I find that code and architecture is being discussed a lot more. However, I still feel that unit testing is still not discussed as much and that there aren't that many great testing tools and frameworks.

I wrote manual mocks for year before deciding to either find or create a mock framework that behaved like .NET mocking frameworks like NSubstitute and Moq. I was lucky to stumble over a mock library called Stubber, which implemented mocking in a clean way. However, it lacked a bunch of features, used a singleton to register function calls and also used function memory addresses to refer to functions. The latter was very error-prone and made mocks fail for unsupported architectures and release builds...and eventually broke completely when Swift no longer provided stable memory addresses to functions.

I have therefore taken the core of Stubber and created a tiny mocking library that I call MockingKit. It is a life-saver to me and a tool that I use in most of my projects. I however struggle with getting some traction, and would love more eyes on the library. I am really happy with the result and use it in almost all of my projects and hope that it could be of great help to others as well.

I therefore hope that posting a link to the project in this forum may give the library a little attention and that I hopefully get to hear back from some of you regarding it.

You can find the project here:

Best

Daniel

4 Likes
Terms of Service

Privacy Policy

Cookie Policy