I’ve recently been trying my hand at writing a bit of Swift, and one of the things that I do love is being able to try out code in Playgrounds. It’s especially nice to use Playgrounds for coding in isolation from the rest of an app, which can help keep functionality isolated, avoid tightly coupling code, and other jargon phrases besides.
Unfortunately, I can’t use Playgrounds as much as I’d like, because I like to use Test-Driven Devlopment (TDD), and Playgrounds don’t really play nicely with this.
The problem with using Playgrounds for TDD is that once you’re done with your Playground you move the code into your app and throw the Playground away - and along with it all the validation which demostrates that the code is working correctly. When using TDD you’re supposed keep and run those tests, in order to continually validate that functionality as changes are made in the future.
Wouldn’t it be really cool if somehow you could write your code in a Playground alongside the unit tests which validate the code. That way, once you’ve finished your class you could move the code and the tests back into your app, and get the best of both worlds.
Well, the good news is, you can!Read on →