O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Challenge: Test Invalid JSON Dictionary

The first challenge in Chapter 28 was to improve the handling of faulty JSON by ScheduleFetcher’s courseFromDictionary(_:) method.

In this chapter, you only tested that the method behaved correctly when it was provided with valid JSON. Create another test where you pass invalid JSON to the method. Assert that the Course object that is returned is nil.

Think about how much easier it would have been to complete the original challenge if you were able to run your new unit test that passes invalid JSON to courseFromDictionary(_:) as you were implementing the method. Having tests makes writing code easier!

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required