How to mock NSURLConnection.sendAsynchronousRequest in unit testing?

Would iOS developers be better served investing in QA over unit testing?

  • I suppose the real answer is a combination of “developers should do both” and “it depends”. But given the constraints of most iOS projects, I wonder if developers would be better served investing in human QA over more testing in code. It seems as though many developers — especially on iOS — conflate beta testing and QA. Sure, beta testing is an important part of QA, but properly testing an app prior to release is so much more than just releasing it to a small pool of beta testers. My current plan for App Cubby is to take the money I would be paying an engineer to write tests and instead develop better testing procedures.  Compared to the $100-200/hr. most iOS engineers charge, I can spend a lot of money on free and/or cheap testers and give rewards for following detailed testing scripts and finding bugs. I’m curious to hear about how other iOS developers do testing in code and whether it has been demonstrably cost effective. And I’d also love to hear from developers who do thorough QA testing and want to share about their strategy and procedures.

  • Answer:

    Here at Objective-Cologne there was a great presentation by Alexander Repty about using UIAutomation to effectively do something in between unit tests and human QA. You generate scripts in Instruments by performing user tasks, and compile them into a test suite. One other interesting script that Alexander uses is a random tapper test. It randomly generates taps all around the screen at random places. He says he regularly finds bugs with this test. (I saw Dirk Stoop do something similar with his mouse a few years ago, clicking all over his interface, and trying to generate crashes.)

Drew McCormack at Quora Visit the source

Was this solution helpful to you?

Other answers

FWIW, whenever there's a budget for it, we try to do both. Unit testing and QA testing address two different aspects of software development; unit tests validate that the individual parts of your software work well, and encapsulate the developer knowledge that went into building them. They lower the cost of documenting the code, and make updates and improvements easier to maintain—as I like to think of them, they create a cocoon of safety in which a developer can introduce change without having to worry about the consequences. QA testing, on the other hand, validates that a software is ready for production by answering the question “from the point of view of the user, does the product do X, Y, and Z?” All the unit tests in the world aren't going to answer that question, because they're concerned with the individual pieces of your software, and not with the way they interact together to create a working product. (Incidentally, QA testing can answer the question asked by unit tests, but, whereas the latter run automatically, QA must be done by hand, which makes it slow, expensive, and imprecise.) So, to more directly answer your question, in my experience: Unit testing is a future-looking investment. A proper testing harness ensures that your developers are freer to focus on solving new problems because they don't have to worry about stepping on the toes of the existing code. As a bonus, it encapsulates the assumptions that developers make when they write the code, reducing the cost of documentation. QA focuses on whether the product in a given state is ready for prime time. Unlike Unit Testing, which is a tool that is useful for ongoing development, QA is something you do only when you think the software is ready to go. In other words, a unit test failure is expected—which is why unit testing is largely automated—whereas a failure in QA means you've wasted your tester's time with a product that is not ready. That said, if I only had a choice between one or the other, I would pick QA over unit testing—but I only do so when I absolutely cannot convince a client otherwise, and I fully expect the overall cost of a project to be higher in the long run because of it.

Marco Tabini

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.