NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

What is a pragmatic approach to testing Swift?

Recorded – watch the full episode on YouTube.

What is a good approach to testing for Swift developers?

Ellen Shapiro: It's definitely something where I feel like my approach to testing is very pragmatic and I think that's something that people have connected with because there's a lot of people who just have a really hard time figuring out where to start with testing.

Because when you start digging into it and you start seeing, “okay, you need to do everything in TDD or you need to do all of this.” And it's just like, man crawl before you walk, walk before you run, run before you fly. One of the things that I have always been really interested in is actually UI testing. Because one of the things that I've seen is no matter what the state of your code base is, you can always test the UI and make sure it's doing what the app needs to do for customers.

“No matter what the state of your code base is, you can always test the UI and make sure it's doing what the app needs to do for customers.”

Are the people that are actually using your application, going to be able to use it the way that they want to. And that's something that you can test no matter what pit of snakes is in your code banks. I did a talk in 2016 at UIKonf where I called it “outside in,” because the movie inside out had just come out, and it's sort of the idea of putting a scaffolding of UI tests up around your application so that you sort of preserve the facade.

If you've ever been in like an older European city, even in Chicago, sometimes they'll like have like an art deco building or something. And they'll put all the scaffolding up around the very historic facade. And then they'll go in the back where it's just like brick that's been falling apart for 50 years and they'll just completely destroy the whole thing, but they'll have that scaffolding up in order to hold up the part that everybody else sees.

You can't see all the stuff that's happening in the background, making the building stronger and not collapse. And what UI tests do is provide that same scaffolding. Once you have this assurance that this is still going to work for the people who need it to work, then you can start just hammering stuff out in the back and making things better with this sort of safety net.

It's also something that's nice in terms of, if you're new to an app it's a good way to familiarize yourself with what the app actually does. What is the app supposed to do versus what does the app do? Because there are either bugs or there are just features that never got documented or... I've definitely come into a situation where I'm like, okay, well, is there any documentation of what our feature set is? And they're like, it's the app. And I'm like, that's not ideal. But this is the other thing that you do when you add some of those UI tests is you sort of inadvertently add some documentation of what is it even supposed to be doing.

This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.

Listen on Apple Podcasts

Hacking with Swift is sponsored by ViRE

SPONSORED ViRE offers discoverable way of working with regex. It provides really readable regex experience, code complete & cheat sheet, unit tests, powerful replace system, step-by-step search & replace, regex visual scheme, regex history & playground. ViRE is available on Mac & iPad.

Download on the App Store

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift (Vapor Edition) Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Server-Side Swift (Kitura Edition) Buy Beyond Code

Was this page useful? Let us know!

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.