In this post, I’m going to show how you can leverage arrays in your mocks to write better quality and more readable unit tests that might help you catch bugs in your code that you didn’t even know existed.

What are unit tests and mocks?

Although I’m not going to cover in detail what mocks and unit tests are, it’s often useful to start with a quick zoom out.

Unit Testing

Unit testing is a way in which we can test the behaviour and functionality of individual chunks of code.

Calculator struct with a multiply function

We might want…

Ben Gilroy

Senior iOS Engineer at Kin + Carta Create EU

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store