A Design Pattern for Tests that Do Real Networking

Shares

I try to avoid asynchronous tests because they’re slow. But sometimes they’re worth having. When you do have them, it’s worth spending extra effort to make them as fast as possible.

My mistake was that I only focused on the speed of the happy path. Today, I learned a way to improve the speed of failure scenarios, at least around testing network requests.

Continue reading

I’m Pretty Sure Most of Us Are Wrong about XCTestCase tearDown…

Shares

Since 2001, I’ve relied on an understanding of test execution flow in xUnit frameworks. But somewhere along the way, my understanding of the XCTestCase life cycle got messed up. I picked up an assumption that’s just wrong.

At best, it’s an assumption that can bloat our test runs. At worst, it can wreak havoc.

When is an XCTestCase deallocated?

This is the big question. I had it right for a long time, but then I lost it.

Continue reading

Generate Test Scaffolding & Stay Focused

Quickly generate code for either Swift or Objective-C. Code snippets provided for both Xcode and AppCode.

Where Will Jon Be in Fall of 2016?

Shares

Do you enjoy conferences and workshops? I’m looking forward to attending, teaching, and speaking at these events in the fall of 2016…

Developing a Design Sense for Your Code

First up is something I’m attending.

Continue reading

How Can Swift Language Features Improve Testability?

I learned how to write testable code in C++ and Objective-C. But what about Swift?

The features and the overall “feel” of a language can have a big impact on how we express our code. Many of you know this well, because you started Swift early, and are miles ahead of me. I’m delighted to play catch-up. Swift’s features are like new toys! …But how do they affect testability?

Continue reading

TDD Sample App: The Complete Collection …So Far

Shares

When I began my TDD Sample App, my hope was that it would help us explore a number of topics around TDD and Clean Code.

On one hand, the app itself has barely progressed. However, the blog posts cover a surprising variety of topics.

Continue reading

Mental Block? This Is One Weird Trick for Improving Your Code — Really

You face a problem with your code. Maybe something is bugging you about the design approach. Or maybe you’re just plain stuck. What can you do to break through a mental block?

"Free Your Mind" graffiti

free your mind by justanotherhuman, used under CC BY-NC 2.0 / Cropped from original

During one job interview, I remember asking how the candidate approached problem solving. That candidate’s answer has stuck with me over the years:

Continue reading

The Powerful Hidden Benefit of Testing View Controllers

Shares

I’ve been unit testing view controllers for as long as I’ve worked in iOS. My screencast How to Do UIViewController TDD is for folks who want to do TDD, but couldn’t figure out how in a programming model centered around view controllers.

But for every person who wants to know how, there are others who question the whole idea. They wonder if unit testing view controllers is worth it at all. So this time let’s skip the “how” and focus on the “why”.

One reader asked me how to win over a team lead who is test-reluctant. The team lead wanted the reader to stop spending time writing unit tests for view controllers. “He questioned why I unit test UI when it seems to take a long time and does not seem necessary.”

Continue reading

How to Make Specialized Test Assertions in Swift

Shares

When a test fails, we want to know the location of the failure. Getting this information in Objective-C required us to dance with the preprocessor. But with Swift, it’s much more straightforward.

Continue reading

Look, Mom! My First Spike Solution in Swift

Swift, here I come!

It’s time to start another version of the MarvelBrowser project. As I did with the Objective-C version, I begin the Swift version with a spike solution. But the first time was to see if I could satisfy Marvel’s authentication requirements. Basically, I needed to get the incantation correct. This time, I know the steps to take, but I will repeat them in Swift.

I have two goals:

  1. Make it work
  2. Make it Swifty

Could you give me feedback on the Swiftiness of my code?

Continue reading

It’s About Time! Quality Coding Embraces Swift

You spoke. The world is shifting. It’s time for Quality Coding to go Swift!

Better late than never.

Swift programming language logo

Continue reading

>