Focused Testing in Xcode

Posted on

I’ve set a very informal goal to produce content for this blog on a daily basis. We’re not there yet, but before the night is lost, here is a quick Xcode tip I fell into today.

So I’m using RestKit in a client project. In this project we POST and PUT lots of records. RestKit does not currently have an option to, when serializing a record, include those record attributes which are nil as nulls in the resulting JSON. While there has been an ongoing ticket for this feature, my own release date is approaching and so I dug in this weekend to see what I could do.

As part of adding this code, I wanted to run and make additions to the RestKit test suite, but running the whole suite over and over as you are making very specific changes is a bit of a time waste. Here is my Xcode tip.

When working in an Xcode project that has lots of tests, you can temporarily setup Xcode to only run the tests you are working on by editing the schema. In the schema editor, look for the test action and from there you can expand the test target.

Edit Xcode Schema to Focus Your Testing

You’ll see checkboxes for each test file and they expand further for each test case. Check and uncheck to focus in on the tests you are working around. Hold down the Option key as you click on the checkboxes to turn them all on/off with a single click.

This can seriously speed up your editing cycle. Just make sure to switch them all back on (or do this change on a schema that isn’t shared in the repo) and verify that the full test suite passes before you commit your changes.

As for my feature, I think I have it working, but will let things settle down before I generate a nice pull request for the RestKit development branch.