So ... I'm trying to set up a unit test in my iPhone app, but I'm having some problems I am trying to test my model squares but they participate directly from NSManagedObject. I'm sure this is a problem, but I do not know how to go around it.
Everything is growing and running as expected, but I get this error when I call the testing class:
unknown. M: 0: 0 Unfolded selector sent for example 0xc2b120
If I follow my purpose in my tests, then I completely end up with another error, But it still does not help me.
If I instantiate my model like this:
Entry = [[TIME INDILA ALOCK] IN WITH WITH ENTTY: NIL DALENIMANGED Object CONTEX: NIEL];
Then I end up with this error on the runtime:
A NSManagedObject of Class 'Time Entry' should have a valid NSEntityDescription.
If I try this like this:
Entry = [[TimeInantry Alok] init];
Then I end with this error:
0xc2b120 sent to unknown selector for example
And if I pattern:
model = [[NSManed object model merged ModellFrand bundle: zero]];] NSLog (@ "model:% @", model); Coordination = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: Model]; Store = [Sync addPersistentStoreWithType: NSInMemoryStoreType Configuration: Zero URL: Zero Option: Zero Error: NULL]; Ctx = [[nsmanned object contact alooc] INIT]; [CTX Setperstant Store Coordinator: Coordination]; Entry = (TimeEnterry *) [NSTTTDCature DineWebbaseFireEfinName: @ "Time Entry" Managed Object Contains: CTX];
Then I get this error:
Could not locate a unit named 'Time Entry' in this model.
Actually my question is: How can I check the class from NSManagedObject?
Start an NSManagedObject, you need an entity. Thus, whatever you tried for the first time - either is passing zero
for the unit or using bare code (which is the name of the NSMD object Not supported on) - did not work. You are doing the right thing by using the - [NSEntityDescription insertNewObjectForEntityForName: inManagedObjectContext:]
object, all you need to do is:
- Make sure the unit timer is your Data exists in the model.
- Make sure that unit is connected to TimeEntry in your data model class in TimeEntry.
- Make sure your data model is actually loaded with your tests.
Note that as long as you do not want to test / delete specificity, you will not normally need to add a continuous store to your coordinator (and if you have your app In a SQLite continuous store, I strongly suggest to use one of my tests; Different display characteristics and capabilities in different continuous store types There are questions.)
To ensure your data model is loaded, you find it very useful which I think is actually to load the URL to load it It seems, just hope that you put it in the right place and that -MergedModelFromBundles:
will do the right thing, I will make it a member of your unit test bundle goal, so it will be useful for your unit test bundle resources In sync Has been engaged. In this way you can get the path or url just by using a proper NSBundle method.
Finally, you want to set up your core data firmness stack - model, consistent store coordinator in a -setup
method in case of your test, and a scratch Reference - or in a test case basis class, in a -setup
method, if you want to create more than one test case class (same persistence heap and -TearDown
methods The tear goes down.)
Comments
Post a Comment