Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Justin,</p> <p>What I do for question #1 is to create an actual NSManagedObjectContext but create an im-memory persistence store. Nothing hits the disk and I test the CoreData version of the truth.</p> <p>I have a MWCoreDataTest class (extends in my case GTMTestCase) that builds the moc and initializes the persistence store</p> <pre><code> - (NSManagedObjectContext *) managedObjectContext { if (managedObjectContext != nil) { return managedObjectContext; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { managedObjectContext = [[NSManagedObjectContext alloc] init]; [managedObjectContext setPersistentStoreCoordinator: coordinator]; } return managedObjectContext; } - (NSPersistentStoreCoordinator*)persistentStoreCoordinator; { if (persistentStoreCoordinator) return persistentStoreCoordinator; NSError* error = nil; NSManagedObjectModel *mom = [self managedObjectModel]; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:&amp;error]) { [[NSApplication sharedApplication] presentError:error]; return nil; } return persistentStoreCoordinator; } </code></pre> <p>WRT #2, I think that's ok - if you plan on testing more than one behavior in the class, move the </p> <pre><code>[addItemWindowController setValue:mockNameField forKey:@"itemNameTextField"]; </code></pre> <p>to the testAdding.. method</p> <p>If you solve #1, then you could just set the itemNameText field to nil and your save validation would trigger.</p> <p>WRT #3, I would validate that building a mock on NSApp === building a mock on NSApplication</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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