Quality Coding
Shares
Emoji: Female Factory Worker

Need Feedback Now? Quickly Hack a Spike Test

Shares

You’re building a new network call to a server. The thing that will actually use this call isn’t ready. But you’re anxious to see the call work in a full round-trip to the actual server. Basically, you want to know: does this part of the code work? How can you get the feedback you need?

Answer: Quickly hack together any way that works.

The agile workflow is to build, validate, and adjust course. Extreme Programming teaches us to use many feedback loops. And fast feedback is the primary benefit of TDD. …But TDD isn’t the only way I’ve gotten feedback on my Marvel Browser:

  • I did a spike solution to learn how to do request authentication for the Marvel Comics API.
  • Having TDD’d that authentication, I wrote an acceptance test to ensure that it works.

This time, I want to combine these two approaches. It’s a hybrid for which I don’t have a name. Maybe a “spike test”?

[This post is part of the series TDD Sample App: The Complete Collection …So Far]

Continue reading

Emoji: Man Facepalming

How a TDD Mistake Revealed an Error in My Design

Shares

My TDD has improved since I first started in 2001. But even today, I make mistakes. The trick is to learn to recognize TDD mistakes. Then, learn to “listen” to them: what is it trying to tell me about the design?

Follow along as I recount the latest steps in Marvel Browser, the iOS TDD sample app. Can you spot the errors before I point them out?

[This post is part of the series TDD Sample App: The Complete Collection …So Far]

Continue reading

Don't Lose Your “Flow”… Quickly Generate Test Code!

Subscribe to Download these FREE Code Snippets
Languages: Swift and Objective-C
IDEs: Xcode and AppCode

You’ll get our newsletter on Clean Code techniques for iOS developers. And you’ll get instant access to these code snippets!
We take your privacy seriously. See our privacy policy here.

Can TDD Be Simple? With Preparation, Yes

Shares

TDD doesn’t make anything happen automatically. You really need to level up on two other skills as you go: design, and unit testing. Doing so can shift TDD from being daunting to being simple.

Let’s look at how a change to unit testing empowers TDD.

Continue reading

Simpsons bully Nelson Muntz mocking,

Type Safety, 100% Coverage, and Uncle Bob: Who’s Right?

Robert Martin “Uncle Bob” creates strong impressions, with outlandish costumes and black-and-white statements. If you understand that this is his didactic style, you can appreciate him. But people seem to enjoy jumping on statements rather than trying to grasp the whole.

I’m referring to the sentence: “You don’t need static type checking if you have 100% unit test coverage.”

This is one of the closing statements from a blog post, Type Wars. Various people jumped all over this, with much LOL.

Who’s right? Is Uncle Bob right? Are his detractors right?

Applying my faith to life, I find that “right and wrong” isn’t a helpful filter.

I want to start by trying to see the points of view of the detractors. But then I want to expand on Uncle Bob’s statement, from my point of view. Finally, what do I think this means for Swift?

Continue reading

Emoji: Wrench and Hammer

What Are Your Favorite Tools for Productive Programming?

Shares

I’m always on the lookout for new tools. Are you? Anything that might increase programmer productivity is worth a look.

You know that I’m a big AppCode fan. It saves huge amounts of time. And doing so within an IDE helps me stay “in the zone.”

I’ve shared about 6 Simple Power Tools for Better Git Use. Thanks to reader comments, I learned about Oh-My-Zsh for command-line, and SourceTree for GUI. AppCode also provides great Git support.

So I’d love to hear more from you. What are your favorite tools for productive programming? Share your tips in the comments below!

Emoji: Man and Woman Holding Hands

How to Make Your Own OCHamcrest Matcher for Powerful Asserts

Shares

OCHamcrest matchers are predicates on steroids:

  • You can combine them to create expressive assertions.
  • They describe mismatches in detail, reducing the need to debug.

But OCHamcrest isn’t just a library of powerful matchers. It’s a framework for creating your own.

By creating a custom matcher, you create a small Domain-Specific Language. This will make your unit tests easier to write, easier to read, and self-diagnosing!

In this post, we’ll walk through the 9 steps of creating a custom OCHamcrest matcher.

[This post is part of the series TDD Sample App: The Complete Collection …So Far]

Continue reading

AppCode vs. Xcode Unit Testing Battle

Share

AppCode vs. Xcode: Which is easier to use for unit testing? Which gives better feedback?

I’ve written about the big improvements to OCMockito’s error reporting. But when I ran the tests, I saw striking differences between the two IDEs.

Continue reading

Swift custom XCTest file template

Get the Swift Unit Testing Template You’re Missing

Shares

Back in Xcode 4 days, Apple’s file template for Objective-C unit tests was awkward and bloated. So I made my own.

Fast-forward several years. I’m coding in Swift now. The first thing I want is unit tests — let’s create a new test suite.

Why am I not surprised that Apple’s template for Swift unit tests is filled with cruft?

Fine. I made my own.

Continue reading

YO DAWG, I HEARD YOU LIKE UNIT TESTS, SO I PUT UNIT TESTS IN YOUR UNIT TESTS SO YOU CAN TEST TESTS WHILE YOU TEST

How to Avoid Problems with Assertion Test Helpers

Shares

Refactor tests, I say. Extract those helper methods. …But sometimes it’s not that simple! You have be careful when extracting an assertion test helper. Especially when it becomes long or complex.

[This post is part of the series TDD Sample App: The Complete Collection …So Far]

Continue reading

Emoji: Thinking Face

Who Tests the Tests? Increase Confidence in Your Tests

Shares

Tests are code, too. So you may ask: who tests the tests? “Who watches the watchmen?” Is TDD flawed, because it’s “turtles all the way down”?

This is about speed. The more I trust the tests over a section of code, the more fearless I can be with bold refactoring. Fearless refactoring means I don’t spend time checking correctness. That’s what the tests are for! Instead, I can focus completely on good design.

So how can you increase confidence in your test code?

Continue reading

1 3 4 5 6 7 12
>