diff --git a/Magical Record.xcodeproj/project.pbxproj b/Magical Record.xcodeproj/project.pbxproj index ba30f20..757a574 100644 --- a/Magical Record.xcodeproj/project.pbxproj +++ b/Magical Record.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ C753897413DB61CE002B2F57 /* GHUnitTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = C753897313DB61CE002B2F57 /* GHUnitTestMain.m */; }; C753897613DB6322002B2F57 /* GHUnit.framework in Copy GHUnit into App Bundle */ = {isa = PBXBuildFile; fileRef = C721C84113D0C6460097AB6F /* GHUnit.framework */; }; C75A4E7313D0D88D00790CEB /* NSManagedObject+MagicalDataImport.m in Sources */ = {isa = PBXBuildFile; fileRef = C75A4E7213D0D88D00790CEB /* NSManagedObject+MagicalDataImport.m */; }; + C763783213E10BEC0009A6CA /* GHUnitIOSTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = C763783113E10BEC0009A6CA /* GHUnitIOSTestMain.m */; }; C76AF7E513DBC08F00CE2E05 /* FixtureHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = C77E5FBA13D0D2AE00298F87 /* FixtureHelpers.m */; }; C76AF7E613DBC08F00CE2E05 /* MagicalRecordHelperTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C77E5FA713D0CBDE00298F87 /* MagicalRecordHelperTests.m */; }; C76AF7E713DBC08F00CE2E05 /* ImportSingleEntityTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C77E5FB713D0D25100298F87 /* ImportSingleEntityTests.m */; }; @@ -58,7 +59,6 @@ C77E5F9B13D0CA0A00298F87 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C721C7E213D0C3A00097AB6F /* CoreData.framework */; }; C77E5F9E13D0CA2100298F87 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C77E5F9C13D0CA1800298F87 /* CoreGraphics.framework */; }; C77E5FA113D0CA3000298F87 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C77E5F9F13D0CA2700298F87 /* UIKit.framework */; }; - C77E5FA413D0CAD000298F87 /* GHUnitIOSTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = C77E5FA213D0CAC700298F87 /* GHUnitIOSTestMain.m */; }; C77E5FA813D0CBDE00298F87 /* MagicalRecordHelperTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C77E5FA713D0CBDE00298F87 /* MagicalRecordHelperTests.m */; }; C77E5FB313D0D1D100298F87 /* SingleEntityWithNoRelationships.plist in Resources */ = {isa = PBXBuildFile; fileRef = C77E5FB213D0D1D100298F87 /* SingleEntityWithNoRelationships.plist */; }; C77E5FB513D0D1EC00298F87 /* SampleJSONDataForImport.json in Resources */ = {isa = PBXBuildFile; fileRef = C77E5FB413D0D1EC00298F87 /* SampleJSONDataForImport.json */; }; @@ -174,12 +174,12 @@ C753897313DB61CE002B2F57 /* GHUnitTestMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHUnitTestMain.m; sourceTree = ""; }; C75A4E7113D0D88D00790CEB /* NSManagedObject+MagicalDataImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+MagicalDataImport.h"; sourceTree = ""; }; C75A4E7213D0D88D00790CEB /* NSManagedObject+MagicalDataImport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+MagicalDataImport.m"; sourceTree = ""; }; + C763783113E10BEC0009A6CA /* GHUnitIOSTestMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHUnitIOSTestMain.m; sourceTree = ""; }; C76AF7F813DBE8D300CE2E05 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = ""; }; C76AF7FA13DBEB5500CE2E05 /* ImportSingleEntityWithRelatedEntitiesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImportSingleEntityWithRelatedEntitiesTests.m; path = "Unit Tests/ImportSingleEntityWithRelatedEntitiesTests.m"; sourceTree = ""; }; C76AF82913DBEE5A00CE2E05 /* SingleRelatedEntity.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = SingleRelatedEntity.json; path = "Unit Tests/Fixtures/SingleRelatedEntity.json"; sourceTree = ""; }; C77E5F9C13D0CA1800298F87 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; C77E5F9F13D0CA2700298F87 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; - C77E5FA213D0CAC700298F87 /* GHUnitIOSTestMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GHUnitIOSTestMain.m; path = "../../../../../../saul/Desktop/iOS Test Frameworks/GHUnitIOSTestMain.m"; sourceTree = ""; }; C77E5FA613D0CBDE00298F87 /* MagicalRecordHelperTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MagicalRecordHelperTests.h; path = "Unit Tests/MagicalRecordHelperTests.h"; sourceTree = ""; }; C77E5FA713D0CBDE00298F87 /* MagicalRecordHelperTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MagicalRecordHelperTests.m; path = "Unit Tests/MagicalRecordHelperTests.m"; sourceTree = ""; }; C77E5FB213D0D1D100298F87 /* SingleEntityWithNoRelationships.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = SingleEntityWithNoRelationships.plist; path = "Unit Tests/Fixtures/SingleEntityWithNoRelationships.plist"; sourceTree = ""; }; @@ -314,7 +314,7 @@ C721C80213D0C3CD0097AB6F /* iOS App Unit Tests */ = { isa = PBXGroup; children = ( - C77E5FA213D0CAC700298F87 /* GHUnitIOSTestMain.m */, + C763783113E10BEC0009A6CA /* GHUnitIOSTestMain.m */, C721C80313D0C3CD0097AB6F /* Supporting Files */, ); path = "iOS App Unit Tests"; @@ -755,7 +755,6 @@ C721C87313D0C7030097AB6F /* NSPersistentStore+MagicalRecord.m in Sources */, C721C87513D0C7030097AB6F /* NSPersistentStoreCoordinator+MagicalRecord.m in Sources */, C721C87713D0C7030097AB6F /* MagicalRecordHelpers.m in Sources */, - C77E5FA413D0CAD000298F87 /* GHUnitIOSTestMain.m in Sources */, C77E5FA813D0CBDE00298F87 /* MagicalRecordHelperTests.m in Sources */, C77E5FB813D0D25100298F87 /* ImportSingleEntityTests.m in Sources */, C77E5FBB13D0D2AE00298F87 /* FixtureHelpers.m in Sources */, @@ -777,6 +776,7 @@ C7BD889313DBFA6200274567 /* DifferentClassNameMapping.m in Sources */, C7BD889413DBFA6200274567 /* SingleEntityWithNoRelationships.m in Sources */, C7BD889513DBFA6200274567 /* SingleRelatedEntity.m in Sources */, + C763783213E10BEC0009A6CA /* GHUnitIOSTestMain.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iOS App Unit Tests/GHUnitIOSTestMain.m b/iOS App Unit Tests/GHUnitIOSTestMain.m new file mode 100644 index 0000000..9c15b47 --- /dev/null +++ b/iOS App Unit Tests/GHUnitIOSTestMain.m @@ -0,0 +1,84 @@ +// +// GHUnitIOSTestMain.m +// GHUnitIPhone +// +// Created by Gabriel Handford on 1/25/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import + +// If you are using the framework +#import +// If you are using the static library and importing header files manually +//#import "GHUnit.h" + +// Default exception handler +void exceptionHandler(NSException *exception); +void exceptionHandler(NSException *exception) { + NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception)); +} + +int main(int argc, char *argv[]) { + + /*! + For debugging: + Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode). + Then go in the "Arguments" tab. You can add the following environment variables: + + Default: Set to: + NSDebugEnabled NO "YES" + NSZombieEnabled NO "YES" + NSDeallocateZombies NO "YES" + NSHangOnUncaughtException NO "YES" + + NSEnableAutoreleasePool YES "NO" + NSAutoreleaseFreedObjectCheckEnabled NO "YES" + NSAutoreleaseHighWaterMark 0 non-negative integer + NSAutoreleaseHighWaterResolution 0 non-negative integer + + For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html + + For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html + */ + + NSSetUncaughtExceptionHandler(&exceptionHandler); + + @autoreleasepool { + + // Register any special test case classes + //[[GHTesting sharedInstance] registerClassName:@"GHSpecialTestCase"]; + + int retVal = 0; + // If GHUNIT_CLI is set we are using the command line interface and run the tests + // Otherwise load the GUI app + if (getenv("GHUNIT_CLI")) { + retVal = [GHTestRunner run]; + } else { + retVal = UIApplicationMain(argc, argv, nil, @"GHUnitIPhoneAppDelegate"); + } + + return retVal; + } +}