title: Unit Testing Example with OCUnit
body: <p>I'm really struggling to understand unit testing. I do understand the importance of TDD, but all the examples of unit testing I read about seem to be extremely simple and trivial. For example, testing to make sure a property is set or if memory is allocated to an array. Why? If I code out <code>..alloc] init]</code>, do I really need to make sure it works?</p>
  
  <p>I'm new to development so I'm sure I'm missing something here, especially with all the craze surrounding TDD. </p>
  
  <p>I think my main issue is I can't find any practical examples. Here is a method <code>setReminderId</code>  that seems to be a good candidate for testing. What would a useful unit test look like to make sure this is working? (using OCUnit)</p>
  
  <pre><code>- (NSNumber *)setReminderId: (NSDictionary *)reminderData
  {
      NSNumber *currentReminderId = [[NSUserDefaults standardUserDefaults] objectForKey:@"currentReminderId"];
      if (currentReminderId) {
          // Increment the last reminderId
          currentReminderId = @(currentReminderId.intValue + 1);
      }
      else {
          // Set to 0 if it doesn't already exist
          currentReminderId = @0;
      }
      // Update currentReminderId to model
      [[NSUserDefaults standardUserDefaults] setObject:currentReminderId forKey:@"currentReminderId"];
  
      return currentReminderId;
  }
  </code></pre>