jeudi 4 avril 2019

Create CoreData object in tests with a simple init

I have a set of NSManagedObject subclasses which are used by the ClassToBeTested.

The ClassToBeTested operates just on a few properties of the NSManagedObject subclasses and doesn't need relationships or the whole CoreData stack.

Can I somehow use the same objects in tests by just creating them in a regular way:

        let template = CoreDataClass()
        template.name = randomString(length: 40) // This fails!
        templates.append(template)

Currently it fails with error:

failed: caught "NSInvalidArgumentException", "-[CoreDataClass setTemplate_name:]: unrecognized selector sent to instance 0x600000af4c40"

Aucun commentaire:

Enregistrer un commentaire