• Unit testing framework and Asynchronous calls

    In my quest for information on writing test cases within the confines of unit testing framework, it became evident quite quickly that the tests are synchronous and asynchronous calls will never complete thereby rendering the test case useless. Since all networking code should be asynchronous (in my expert opinion), I had to find a way to handle this.

    After a few quick searches, I found that my issue wasn't uncommon. The most straightforward answer to this question is some code called AssertEventually by a developer named Luke Redpath. Straightforward in that the calling method is not complex; however, there is a big chunk of code behind it that has me a little concerned.

    The more I've read about this, the more it looks like I have to spin my own run loop during the test such as described on a mailing list like this:

    while (!_isDone)
    {
    	[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
    }

    While this should work, it isn't the most efficient way to do things, but at this point, I'm not sure there are other options.

  • Utility of Unit Tests in software development

    Over the years, I've read a little about unit testing and heard it talked about at WWDC once or twice, but never thought much of it and didn't see much of a need for it. Recently I've started to look at it again and have done a little research on the concept. I found a reference that seems to sum up the flaws of unit tests.

    A test is not a unit test if:

    It talks to the database
    It communicates across the network
    It touches the file system
    It can't run at the same time as any of your other unit tests
    You have to do special things to your environment (such as editing config files) to run it.

    Of all the projects I've worked on over the years, most, if not all, of them have had external dependencies such as network connections, handheld devices, or files on disk and therefore most of the unit tests I'd write adhering to the above rules, would barely exercise the app. If I wrote unit tests to simulate networks, I'd have to hard code in test data which lets us test one path in our app if we assume the data on the network never changes which is quite unlikely.

    So, effectively unit tests are useless. I'm sure that someone will argue with me about this point, but if we assume I'm correct in the limited utility of unit tests, can tests be written that are useful?

    Of course, we can write tests using the unit test framework (like OCUnit in Xcode 4). The test aren't unit tests, they're more like functional or integration tests that have external dependencies. This will let us test error conditions and see how different parts of the code will act in a real world environment.

    It appears that Wil Shipley of Delicious Library fame seems to have similar views to me on this topic. However, I'm not opposed to functional or integration tests.

    I don't discount the utility of writing "tests" and will be writing some to test chunks of my code, but for the projects I've been on and expect to be on, unit tests have very limited utility and are possibly a poor use of limited resources.

  • Giving Ooma another chance

    The other day I had lunch with some friends and one mentioned that he was reducing his monthly bills by dropping cable, installing solar and switching his home phone to Ooma. He had Ooma for 6 months and was quite pleased with it. I had tried Ooma about 1.5 years ago and written about it; unfortunately my experience back then wasn't as positive. I decided to give it another try as the potential to save money is huge. In the last few years, my phone bill has gradually risen while the features have gone down (I had lots of features with Qwest over a decade ago including a blacklist, then with MCI I had voicemail that forwarded to email. Now I don't even have voicemail as there is an extra charge for it.)

    This time I just plugged the Ooma into the back of my Time Capsule (it had an open port) and forwarded my home phone to the Ooma number for testing. So far through a few calls, there have been no complaints. I'll give it a few weeks and I'm crossing my fingers. Even if I stick with Ooma Premier ($120/yr + $3.50/month for taxes), the cost recovery (including number porting and getting a Telo handset) is about 7 months and then I'll save about $50/month. My regular phone bill will just keep going up, so this may be the only way to keep a home phone without paying through the nose.

    I'm crossing my fingers that this pans out!

  • Google Voice fix for when it stops working

    Today I got notification that I missed a call coming through my Google Voice account. I checked Google Voice and everything was setup correctly; I had also noticed that the Google Voice app on my iPhone didn't notify me of an SMS that I received the other day which was strange.

    Thinking that things may have broken after I ported my cell number to AT&T last month, I deleted my cell number from Google Voice and added it back. While I shouldn't have been surprised, I was when that simply fix made the forwarding work again and notifications started working again in the Google Voice app.

    So, if you have trouble with Google Voice, delete the forwarding number(s) and re-add them.