I have a "Data" class that subclasses "NSManagedObject" with a single bool property "attribute". I've also defined a method "whoisyou" on the class "Data". This code runs in the app, but as soon as I put this code in my UnitTest, Core Data returns a "NSManagedObject" instead of a "Data" object and the "attribute" property works, but the "whoisyou" method throws an "unrecognized selector" exception.
Data *data = [NSEntityDescription insertNewObjectForEntityForName:@"Data" inManagedObjectContext:self.moc]; NSLog(@"TYPE: %@", [data class]); data.attribute = [NSNumber numberWithBool:YES]; STAssertTrue([data.attribute boolValue], @"should have been TRUE"); data.attribute = [NSNumber numberWithBool:NO]; STAssertFalse([data.attribute boolValue], @"should have been FALSE"); [data whoisyou];
What's the deal with the Unit Test environment?