Hello all,
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.