0
votes

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?

1
Are your custom classes .m files included in the tests target? - fabrice truillot de chambrier
well there ya go :-) - post an answer and I'll accept it - FishStix

1 Answers

3
votes

Make sure your custom classes implementation files are included in the unit tests target. :)