Runnable test schemes for Travis CI

February 27th, 2016
#ci #xcode #testing

When I first created ConvenientFileManager I didn't add a unit testing target - what can I say, I was young(er) and foolish. Recently I decided to rectify this grievous error and added a unit testing target. After writing the tests I pushed them to my repo and CI took over. However, Travis CI ran into some trouble when attempting to run this test target, resulting in the following error:

The command "xctool -project ConvenientFileManager.xcodeproj -scheme ConvenientFileManager build -scheme ConvenientFileManagerTests test -sdk iphonesimulator" exited with 1.

Debugging on Travis CI isn't a time efficient task so I needed to reproduce the error on my local machine. However, when I ran the tests via Xcode everything was fine 🤔. Keen to avoid a "it's fine on my computer" moment, I decided to look again at how the tests were executed on Travis. I quickly discovered that my attempt to reproduce the error was fundamentally flawed - I was running the tests via the Xcode UI whereas on Travis I was using xctool. Switching over to the terminal I ran the same command as happens on Travis:

xctool -project ConvenientFileManager.xcodeproj -scheme ConvenientFileManager build -scheme ConvenientFileManagerTests test -sdk iphonesimulator

With the above command, I was able to reproduce the error on my local machine and could begin the process of debugging it. After much investigation I stumbled upon the solution - I had to manually mark the ConvenientFileManagerTests scheme as runnable:

Test scheme marked as runnable

With that tick on Run my tests started running on Travis 😁 - all that hassle because when creating the project I didn't think I needed unit tests so didn't tick the "Include Unit Tests" tickbox 😢. Lesson learnt.

What do you think? Let me know by getting in touch on Twitter - @wibosco