CoreData tn tests returns results of different classes then in the app run

Originator:pv.kazantsev
Number:rdar://20250947 Date Originated:22-Mar-2015 00:53 AM
Status:Duplicate/20452937 Resolved:
Product:iOS Product Version:
Classification: Reproducible:Always
 
Summary:
There are two models - MainEntity and SecondEntity, MainEntity objects contain property otherValues which is to-many to SecondEntity. When I run the application on simulator, I see both Objective-C and Swift return objects of SecondEntity when fetching the otherValue. But in tests otherValues contains objects of SecondEntity_SecondEntity_2 so I can't cast result to SecondEntity which leads to failed tests.

Steps to Reproduce:
1. Open the attached project
2. Run the SwiftTestBug target
3. See two lines in a console:
    'The object is really a SecondEntity: SecondEntity'
    'Expected result: other values are objects of type SecondEntity'
    First one is from Objective-C side and the second one is from Swift side. Both mean that type of returned object is correct.
4. Switch target to 'SwiftTestBug Tests'
5. Run tests
6. See test failed with result: 'The object is expected to be a SecondEntity, not just generic NSManagedObject. Actually it is SecondEntity_SecondEntity_2'.

Expected Results:
Test should not be failed and CoreData in tests should return the results of type SecondEntity.

Actual Results:
Test failed because CoreData returned result of type 'SecondEntity_SecondEntity_2'

Version:
iOS 8.1.3, iOS 8.2, iOS 8.3 beta 3

Configuration:
iOS Simulator

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!