Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're getting this error because you're invoking the method on mockSUT. Due to the way CoreData generates property accessors OCMock can't copy their implementations to the partial mock and therefore they can't be found by the ObjC runtime.</p> <p>When checkStreamingPlayabilityForUser eventually calls self.streamServer self is actually mockSUT and the method 'streamServer' cannot be found.</p> <p>This would work fine if you simply configured the managed object the way you need it for this specific test.</p> <p>FWIW you should never try to mock instances of NSManagedObject, the preferred way to perform these types of test is to simply create test objects in the unit test that fit the configuration you need.</p> <hr> <p>Data driven tests with Core Data:</p> <p>It will help if you create a subclass of SenTestCase or XCTestCase that can manage the CoreData bits for you. This test case subclass should make available an instance of NSManagedObjectContext for your test to use.</p> <p>An actual test might look something like this:</p> <pre><code>@implementation PeopleViewControllerTest - (void)testSomething { NSMutableArray *people = [NSMutableArray new]; [self.managedObjectContext performBlockAndWait:^{ for (int i=0; i &lt; 100; i++) { Person *p = [NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:self.managedObjectContext]; p.firstName = [NSString stringWithFormat:@"First%d", i]; [people addObject:p]; } }]; //return the people PeopleViewController *pvc = ...; id mockPVC = [OCMockObject partialMockForObject:pvc]; [[[mockPVC stub] andReturn:people] fetchedPeople]; //make sure the view controller behaves properly with these 100 people } @end </code></pre> <p>So instead of creating 100 mock instances of NSManagedObject we just create 100 actual objects.</p> <p>We're not trying to test CoreData, just our logic thats built on top of some set of NSManagedObjects. Therefore creating concrete instances of NSManagedObject is fine, but they should be configured to exercise your application's logic.</p> <p>i.e. if you wanted to check email address validation, you might have:</p> <p>p.emailAddress = @"notvalid";</p> <p>//later with some mock object [[[partialMock expect] andReturn:p] person];</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload