mokacoding

unit and acceptance testing, automation, productivity

Archive



Nimble: when to use waitUntil or toEventually

The Nimble matchers framework provides two ways assert expectations on asynchronous code, this post explores when to use one or the other.

XCTest closure based expectations

Testing async code is not simple, but XCTest provides us with all the required tool. This post shows how to wait for an expectation to be fulfilled based on a Swift closure.

How to use dependency injection for classes in Swift

In Swift it is possible to pass a reference to a type itself, not just to an instance of it. This post shows how to use this capability to test legacy code.

Your Git Log Should Tell A Story

A look at the practical benefits of writing descriptive commits

Better Xcode Run Script Build Phases

Practical tips to write "Run Script" build phases in Xcode.

Implicitly vs Force Unwrapping Swift Optionals

A look at what implicitly unwrapping and force unwrap a Swift Optional mean, and how they differ from each other.

Why Implicitly Unwrapping Swift Optionals Is Dangerous

A look at what implicitly unwrapping an Optional value means and why it should be avoided.

Swift Either enum

This post introduces the Either type and shows a practical application of it in Swift, injecting extra cells in a table view.

What is an optional value in Swift

This post looks into one of Swift's most powerful feature: optionals

Maintaining Sanity with Multiple Versions of Xcode

Working with Xcode and Xcode-beta on the same machine can sometimes be confusing, this post shares some tools to help make it less so.

Functional Core Reactive Shell

This is a blogpost version of the content of my talk "Functional Core, Reactive Shell"

Language Agnostic Automation Setup

Every project can benefit from having a set of scripts to automate tasks such as running tests or distributing to testers. When setting up automation for your projects you can use a language agnostic setup. This will make it easier for new team members to get started, and allow you to change the setup without having to change the way the scripts are invoked.

Getting Started With Automation

A collection of tips to get you started with workflow automation, increase productivity, and save time.

Using Swift protocols to abstract third party dependencies and improve testability

Third party code can be hard to test, but you can use Swift's protocols to abstract its details and improve testability

Getting Started With OHHTTPStubs

Good unit tests are fast and deterministic. Testing code that hits the network could undermine this goal, but using OHHTTPStubs we can take back control of our tests. This post explores the advantages of stubbing the network, and provide a guide on how to do it with OHHTTPStubs.

Why hitting the network is bad for your test, and what to do about it

In this post we are going to look at why hitting the network from your unit tests is a bad thing, and introduce some way to solve the problem.

Ruby for iOS Developers - Managing Ruby Tools with Bundler

Between CocoaPods and Fastlane, Ruby is an important part of the iOS developer toolchain. How can we reliably control the versions of the tools our project's automation is using in Ruby? Bundler is a simple way to specify Ruby dependencies and automate their setup.

Ruby for iOS Developers - Managing Ruby Versions

Between CocoaPods and Fastlane, Ruby is an important part of the iOS developer toolchain. Managing versions and gems can be a challenge for developers outside of the Ruby community, but it doesn't have to be. In this two parts post we will see how to simply and reliably handle our Rubies.

Async Testing with Quick and Nimble

A look at how to write tests for async code when using the Quick and Nimble Swift frameworks. This post is part of the Practical Testing in Swift series.

Testing Delegates in Swift with XCTest

In this second post of the Practical Testing in Swift we a look at strategies to test how objects call their delegate methods or set property on them.

Testing callbacks in Swift with XCTest

2015 Retrospective

A retrospective on my consulting business in 2015. What when well, what didn't and how to act on it, how to move forward in 2016. I think my personal experience could be valuable for every iOS freelancer, I have done a couple of things right that helped my business a lot.

Installing Xcode plugins from the terminal with Fastlane

How to install Xcode plugins from the terminal using Fastlane, and persist them across machines.

How to configure Travis CI for iOS testing

A practical guide on how to configure Travis CI to run iOS, and OS X, tests.

How to configure CircleCI for iOS testing

A practical guide on how to configure CircleCI for to run iOS, and OS X, tests.

Fixing Bugs Driven By Tests in Swift

Unit and acceptance test are powerful tools that can be used to identify and fix bugs. Let's see how using a bugged Swift app as an example.

How To Sharpen Your Software Developer Tools

Practical advices on how to keep your tools sharp, master them, and become more productive.

Xcodebuild Destination Cheatsheet

A collection of tips on how to configure the -destination option for the xcodebuild tool.

When to use map, flatMap, or for loops in Swift

Swift allows us to natively iterate over arrays using map. Map could be used to replace every for loop in your code, but that's not a great idea. Map and for have different purposes and should be used appropriately

Automated Xcode version and build numbering via Git

How to configure Xcode to automatically set the version and build number of your projects using Git.

Swift Optionals, Functional Programming, and You

This is the post version of a talk I've been given in the past months. In this post we will demystify functional programming terms like monad and functor, and see how those concepts can be brought back to the every day Swift development, in particular how they can help to deal with optionals in a leaner way.

An even lighter way to use Carthage

Among the options Carthage, an iOS and OS X dependency manager, provides there is the --no-build one. Using this we can integrate dependencies in the form of Xcode projects rather than frameworks, keeping the repository slimmer and the CI time low. This approach is lighter than than the usual way to work with Carthage, but comes with some disadvantages too.

/dev/world/2015 notes of a testing fanboy

I attended /dev/world/2015 in Melbourne this week. It has been a great conference, full of very friendly and smart people. Being a test and automation fanboy I attended as many talks related to that topic as I could. These are my notes.

Enhancing XCTest test cases with Nimble matchers

Nimble is a matchers framework built for Swift that provides powerful and versatile expectations. Writing test within the standard XCTest harness but using Nimble assertions is easier and productive, and a good combination of tools to introduce testing and TDD to colleagues and teams in a frictionless way.

Explicit Dependencies, Swift Edition

A look at how to write classes and structs that expose their dependencies as initialization arguments in Swift.

Explicit Dependencies for Code with No Surprises

Sometimes the idea we get when reading a class interface is different from what is actually going on inside its implementation, for example there could be several hidden dependencies. Making a class dependency explicit in its interface is a useful technique to make the code simpler to understand, and easier to test.

Keep Your Bench Clean

Like good chefs keep their benches clean to make delicious dishes all day long in the restaurants' kitchens, so good developer keep their codebase clean. It all comes down to little habits, the result of which when summed up together is a tidy, clean and easy to maintain software.

How to test UI changes in Xcode 7

One of the characteristic of the UI is that it changes, and there are scenarios in which writing UI tests to assure that the change has happened correctly can be very valuable for the reliability of our apps. Writing such a test is a bit harder than normal, let's see how to do it.

How to add testing dependencies using Carthage, with Swift 2 and Xcode 7

In this little tutorial we will see how to use Cathage, an OS X and iOS depencendy manager, to install libraries written in Swift 2 and Xcode 7, with a focus on the process to get testing dependencies.

Swift Functors, Applicatives, and Monads in Pictures

In this port to Swift of the great of Haskell's "Functors, Applicatives, And Monads In Pictures" we are going to look at these functional programming concepts aided by some very helpful pictures.

XVim, harnessing the king of text editor's power in Xcode

An introduction to the XVim plugin, that adds most Vim keybindings and features to the Xcode IDE, and how this can make you more productive as a developer.

Testing Realm apps

Realm is a mobile database that, unlike CoreData, is easy to test. In this post we will discuss some ideas on how to test an app using Realm as its database.

The value of acceptance testing for mobile projects

Companion blogpost for Gio's talk "Talking myself into the value of acceptance testing" at Melbourne CocoaHeads meetup

Xcode 7 UI testing, a first look

How to get started with UI testing in Xcode 7, recording tests and using the new APIs to assert the state of the application under test.

MailChimp automated workflow for mokacoding weekly

At mokacoding we're big on automation, and we eat our own dog's food! The workflow to write and send new issues of our newsletter, mokacoding weekly, is (partially) automated thanks to some simple Ruby scripting and Mac command line utilities.

Automation with pre-commit hooks

Git provides a mechanism to run one or more scripts before a commit is actually added to the history called pre-commit hook. We can use this hook to run scripts that validate or sanitise the changes to be committed automatically, saving time and brain power, and assuring the quality of the codbase and git log.

xUnique: a tool to avoid Xcode project merge conflicts

How many times when working on a Mac OSX or iOS app with a team have you had a merge conflict on the project.pbxproj file? I guess more than a few, a lot more than a few. Lucky for you there is an handy tool called xUnique that will make the chances of this happening way smaller.

Writing an Expecta custom matcher

Not only Expecta is a simple to use library that allows us to write highly readable code, but it can also be extended by the users with custom matchers. Let's see how to write a custom matcher to gain readability and reuse code in our test suites.

Expecta, a matcher library that speaks English

A test that express is intent clearly is arguably twice as effective as one that doesn't. Writing test in an xSpec style is a good first step to express behaviour clearly, and when matched with a matcher library such as Expecta the results are test that are easy to read and reason about

Specta global before and after each hooks (Updated)

An interesting and powerful, yet not at all documented feature of Spetca are global beforeEach and afterEach hooks. In this post we'll see how to configure them, and how to blacklist classes from running them. Updated for version 0.5

Job stories acceptance tests using KIF and Specta

When writing tests it's very important do be declarative, aiming to have tests that explain how a class is supposed to behave as good as its documentation would do. When talking about acceptance tests we can achieve this kind of clarity by having a 1:1 relationship between the tests and the acceptance criteria for the application. A very effective way to express acceptance criteria is through _job stories_. In this post we'll see how to write acceptance tests that map job stories for our iOS apps, using KIF and Specta.

Better tests with Specta

Writing unit tests for our iOS and OS X projects not only is important, but should be always part of the development cycle. As such the way we write the tests is as important, and having the option to write tests that easily explain their purpose can drastically increase the quality of the suite. Specta and Expecta are two libraries that provide a different way to writing tests than XCTest, let's see what we can gain by using such approach.

Xcode keyboard shortcuts for testing

Keyboard shortcuts are easies way to start increasing your productivity. Let's look at how to run tests in Xcode without ever touching the mouse.

Setting up KIF for iOS acceptance testing

A guide on install and use the KIF framework for iOS acceptance testing.

The state of iOS testing in 2015

In this post we'll look at the main tools and libraries available to write unit and acceptance tests for iOS and OS X applications, as well as the solutions to host Continuous Integration for our projects.

Specta global before and after each hooks

An interesting and powerful, yet not at all documented feature of Spetca are global beforeEach and afterEach hooks. In this post we'll see how to configure them, and how to blacklist classes from running them.

Running Xcode tests from the terminal

In this post we take a look at how to run Xcode tests suites from the terminal with xcodbuild and xcpretty, and why you should do it

How to simplify Calabash acceptance testing with Rake

Rake, the Ruby build utility, can lift off all the typing involved in running the Cucumber/Calabash acceptance tests, saving us a lot of typing time.

Git-iquette

Every team and every project should have a Git-iquette: a set of common practices for managing the git repository.

Setting up Calabash for iOS projects with Cocoapods and Build Configurations

A simple guide that shows the simplest way to install Calabash on an iOS project, by using Build Configurations and CocoaPods.

5 habits that will make you a better software developer

By implementing these 5 small habits you'll kickstart your 2015 and become a better software developer.

Security Tips for Freelance Software Developers

Tips for freelance software developers (and non) to improve the security of laptops, smartphones and website accounts, to keep your and your clients data safe.

Why I don't work on Fridays

Some time ago I learned the hard way that I shouldn't work on Fridays. I've been applying an alternative schedule to my week, and it's working out pretty well.

In-App Purchase Debugging Lessons

A couple of tips learnt the hard way on how to develop and debug In App Purchase support in an iOS app.

Why I (shouldn't have) stopped blogging with Jekyll

I recently decided to move my blog from Ruby and Jekyll, to Metalsmith and Javascript. It turned out to be not as easy as I thought, and a quite stupid choice, but not because of the tech.

CocoaPods and custom Build Configurations

Some tips on how to use CocoaPods and customs build configurations without headaches.

2014 resolutions review

Gradient Backgrounds Studio: Lessons Learned

A caveat when upgrading a Podfile

Sharing assets across iOS projects with CocoaPods, Resource Bundle, and dynamically loaded fonts

Automating iOS Enterprise Deployment with shenzhen

A way of automating the deployment of an iOS app for enterprise distribution using the shenzhen gem.

2013 retrospectives... and 2014 propositions

Taking a look back at 2013, to find good propositions for 2014

Podcasts, grow your brain through soundwaves

A list of the tech podcasts I follow

Rails: adding a new has_many association to an existing model

A little guide on how to edit an existing model adding a new has_many association

Some things I learned in October

A quick summary and memo of interesting things I've learned in October - iOS screen capture, HTML5 game development, ways to improve your coding.

A dive into Xcode projects and workspaces

A look at how Xcode stores information about the project and the workspace

October's Questions

Introducing mokagio's monthly questions, related to iOS, Objective-C, Xcode, xctool, AFNetworking, CocoaPods.

Some things I learned in September

A quick summary and memo of interesting things I've learned in September

Sharing some thoughts on iOS 7

Sharing thoughts by some lead designers on iOS 7.

Setting a Mac for Development

A simple checklist of the basic tools to setup a Mac for development.

Bringing font icons in iOS with MTFontIcon

Introducing MTFontIcon, a CocoaPod library for iOS to improve application development efficiency by using font icons.

A workaround to Xcode 5 GM crash on app submission

A workaround for the unusual crash of Xcode 5 GM during the App Store submission process.

Some things I learned in August

Some things I learned in July

A summary of the things I learned in July 2013.

What I did in a week...

A recap of what I developed during an unusual week left by myself without neither girlfriend nor friends.

A week of time...

A declaration of purposes for what I'm gonna do in the next week.

CocoaPods: the $(inherited) flag

A self memo on how to set the $(inherited) flag on a project using CocoaPods on Xcode.

Some things I learned in June

A summary of the things I learned in June 2013.

mokagio's self memo for Facebook Integration on iOS - Part 1

Step by step guide on how to integrate the Facebook SDK in an iOS app, the right way. Part 1: Facebook Login.

OSX, a scanner, and the drivers drama

The link to the Samsung Printer Drivers, enclosed in a ranting post.

Multiple builds of the same app and TestFlight

How to distribute multiple builds of your iOS app, such as stable, QA and development builds, via TestFlight.

CocoaPods - How to create your own Pod

A step by step guide to create a basic CocoaPod.

CocoaPods!

A brief introduction to CocoaPods, the Objective-C dependencies manager.