Error "dynamic_cast class unconditional" in XCTestCase with master data

I would like to do some unit tests with Core Data in my swift application and this is the first time I use Core Data.

To make my tests easier, I just copied the code generated for the Core Data variables (managedObjectModel, managedObjectContext, ...) from a regular AppDelegate into a test file.

I just want to do something pretty simple and that works in my application:
var user: User = NSEntityDescription.insertNewObjectForEntityForName("User", inManagedObjectContext: context) as User

The thing is, when I run my test, I got this error: swift_dynamicCastClassUnconditional

with EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)

, but when I continue running the program, my test is finished with everything I am waiting for.

EDIT: First I prefixed my project name MyApp.User

, but after I saw that if I put @objc(User)

, I don't need the prefix, so I took the prefix.

Where does this error come from? Why is my test OK at the end?

+3


source to share





All Articles