Testing in iOS - Part 21: Conclusion | Ray Wenderlich

This video reviews the section and reminds you about some strategies to keep in mind.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3530-testing-in-ios/lessons/21

How would you recommend to test classes that have methods like those three:

class BaseServcie {
    func handle(_ json: String){
        fatalError(" handle(json: String) must be overriden")
    func handleError(_ msg: String, code: String, hardError: Bool){
        precondition(false, "this method needs to be overriden")

    func handleSendProgress(_ progress:Int, nativeId:String){


This looks to be used as an abstract class. If you aren’t using this class in production, then I wouldn’t write a test for it. That said, here’s an article about testing methods that have fatalErrors in them:

Hi Brian,

Very organized and clear, really helpful for someone like me know nearly nothing about Unit Testing. I have some questions:

  1. If working on a big project with hundreds of methods, does it make sense to write testing code for each method? Under what circumstances is unit testing must?

  2. Why some companies require testing skills while others not, may use QCs? Any advantage of using QC over unit testing?


@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

Regarding your questions:

  1. Code coverage is a point of contention. Some argue nothing short of 100% is mandated while others will aim for 80%, knowing the critical parts of the app are covered. Ultimately, it’s a team by team choice. Tests do have a cost as you have to not only maintain your code, but your test cases as well.

  2. I’m not sure what you mean by QC - would you elaborate? Thanks!

Hi Brian, thanks.

Regarding QC, I mean in some companies developers do not write test code, but QC (Quality Control, some companies may call QA?) people do tests.

By the way, when is good time to learn write test code? After some years experience as an iOS developer? Someone says capable of writing test code is difference between senior and junior developers, is that true?


Honestly, I’ve never heard of QC. @fahim, Any thoughts on this? As for learning how to write test code, it’s a tool to make sure your code isn’t busted. Like all skills, the more you use tests, the better you will be at determining good tests from bad tests, and what is worth testing and what is not. In such perspective, it’s better to get in the habit of writing them early and often.

Hi Brian,

Thanks for your information about writing test. Regarding QC, some companies may call it QA, sorry for the confusion.

Could you introduce the frameworks related mocking server?

We’ll keep that in mind next time we update the course.