Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 926379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:40:37+00:00 2026-05-15T19:40:37+00:00

I am setting up unit testing for my core data app. I’m running into

  • 0

I am setting up unit testing for my core data app. I’m running into a strange problem in a pretty simple test. The error I’m getting is:

/Developer/Tools/RunPlatformUnitTests.include:451:0 Test rig '/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/Developer/usr/bin/otest' exited abnormally with code 134 (it may have crashed).

The header for my unit tests is:

#import <SenTestingKit/SenTestingKit.h>
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "Unit.h"

@interface UnitLogicTests : SenTestCase {
    NSManagedObjectContext *managedObjectContext;
    NSPersistentStoreCoordinator *persistentStoreCoordinator;
    NSManagedObjectModel *managedObjectModel;
    NSPersistentStore *persistentStore;
}
@end

The implementation is:

#import "UnitLogicTests.h"

@implementation UnitLogicTests

#pragma mark Setup and Teardown
- (void)setUp {
    managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles: nil] retain];
    NSLog(@"model: %@", managedObjectModel);
    persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedObjectModel];
    persistentStore = [persistentStoreCoordinator addPersistentStoreWithType:NSInMemoryStoreType
                                                               configuration:nil
                                                                         URL:nil
                                                                     options:nil 
                                                                       error:NULL];
    managedObjectContext = [[NSManagedObjectContext alloc] init];
    [managedObjectContext setPersistentStoreCoordinator:persistentStoreCoordinator];
}

- (void)tearDown
{
    [managedObjectContext release];
    managedObjectContext = nil;
    NSError *error = nil;
    STAssertTrue([persistentStoreCoordinator removePersistentStore:persistentStore error:&error], 
                 @"couldn't remove persistent store: %@", error);
    persistentStore = nil;
    [persistentStoreCoordinator release];
    persistentStoreCoordinator = nil;
    [managedObjectModel release];
    managedObjectModel = nil;
}

#pragma mark -
#pragma mark Test Cases
- (void)testThatEnvironmentWorks
{
    STAssertNotNil(persistentStore, @"no persistent store");
}


- (void)testNewUnitDefaults {
    Unit *newUnit = [NSEntityDescription insertNewObjectForEntityForName:@"Unit" 
                                                  inManagedObjectContext:managedObjectContext];
    STAssertEquals(newUnit.floorNumber, 1, @"Default value for new Unit's floor number should be 1");

}

@end

If I omit the - (void)testNewUnitDefaults test, then the build completes without errors, so something in that last test is throwing it for a loop. I am new to this, so any assistance would be greatly appreciated!

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:40:38+00:00Added an answer on May 15, 2026 at 7:40 pm

    put a @try …. catch block around your testcase.

    I think loading the model with

    [NSManagedObjectModel mergedModelFromBundles: nil]
    

    did not work as expected

    Using your code for initialization of the core data stack I got an exception

    +entityForName: could not locate an entity named 'Unit' in this model.
    

    Changing the model initialization to the following code works fine:

        // set according to the identifier in your modeltest Info.plist
    
        NSString* path = [[NSBundle bundleWithIdentifier:@"com.yourcompany.ModelTest"] 
                                         pathForResource:@"CoreDataUnitTest_DataModel" 
                                                  ofType:@"mom"];
        NSURL* modelURL = [NSURL URLWithString:path];
        managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
    

    Unit Tests with OCUnit sometimes are a bit tricky as only little information on errors is exposed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 460k
  • Answers 460k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, Red5 can be seen as an FMS alternative. It… May 15, 2026 at 11:49 pm
  • Editorial Team
    Editorial Team added an answer Java applets were modern at the beginning of this century.… May 15, 2026 at 11:49 pm
  • Editorial Team
    Editorial Team added an answer You can't have multiple activities on top at the same… May 15, 2026 at 11:49 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.