spurious EXC_BAD_ACCESS when using observerMock

Discussion of the OCMock framework. If you have patches we would prefer you to send them to the mailing list, but attaching them to a topic is possible, too.

spurious EXC_BAD_ACCESS when using observerMock

Postby infrid » 25 Feb 2013, 18:18

I get many random crashes in my tests when I'm setting up notificaton mock observers..

i.e. I set up observers as follows:
Code: Select all
  id observerMock = [OCMockObject observerMock];
    [[NSNotificationCenter defaultCenter] addMockObserver:observerMock
                                                     name:kVPAdPlayerProgressNotification
                                                   object:self.adPlayer];

    [[observerMock expect]
                   notificationWithName:kVPAdPlayerProgressNotification
                                 object:self.adPlayer
                               userInfo:@{@"time" : @(currentTimeInt)}];


I then sometimes, not every run, but fairly often get EXC_BAD_ACCESS (code=1, address=0x69747269)) on the line of code which dispatches the matching notification.
i.e.
Code: Select all
   [[NSNotificationCenter defaultCenter]
                               postNotificationName:kVPAdPlayerDidReachQuartileNotification
                                             object:self
                                           userInfo:@{@"quartile" : @(quartile), @"trackingEvent" : trackingEvent}];


EDIT:

to clarify - when I comment out the mockObserver code; my unit tests run perfectly every single time, without fail.
infrid
 
Posts: 2
Joined: 25 Feb 2013, 18:15

Return to OCMock



cron