XCTest + CoreData = EXC_BAD_ACCESS(code=EXC_i386_GPFLT)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<unknown>:0: error: -[apiTests testExample] : failed: caught "NSInvalidArgumentException", "*** -[NSURL initFileURLWithPath:]: nil string parameter" | |
( | |
0 CoreFoundation 0x007321e4 __exceptionPreprocess + 180 | |
1 libobjc.A.dylib 0x004ac8e5 objc_exception_throw + 44 | |
2 CoreFoundation 0x00731fbb +[NSException raise:format:] + 139 | |
3 Foundation 0x000c592b -[NSURL(NSURL) initFileURLWithPath:] + 123 | |
4 Foundation 0x000c57fd +[NSURL(NSURL) fileURLWithPath:] + 67 | |
5 apiTests 0x04010023 -[DatabaseManager managedObjectModel] + 291 | |
6 apiTests 0x040102b7 -[DatabaseManager persistentStoreCoordinator] + 503 | |
7 apiTests 0x0400f538 -[DatabaseManager setupContexts] + 312 | |
8 apiTests 0x0400f3ef -[DatabaseManager init] + 143 | |
9 apiTests 0x0400f61a +[DatabaseManager sharedDataManager] + 122 | |
10 apiTests 0x0400fe72 +[DatabaseManager sharedManagedObjectContext] + 194 | |
11 apiTests 0x04010986 -[MCTAuthUserRequest loginUserDone:] + 102 | |
12 libobjc.A.dylib 0x004be82b -[NSObject performSelector:withObject:] + 70 | |
13 apiTests 0x0404fb96 -[NetworkManager operationDone:] + 1494 | |
14 libobjc.A.dylib 0x004be82b -[NSObject performSelector:withObject:] + 70 | |
15 Foundation 0x000fde48 __NSThreadPerformPerform + 285 | |
16 CoreFoundation 0x006bb77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 | |
17 CoreFoundation 0x006bb10b __CFRunLoopDoSources0 + 235 | |
18 CoreFoundation 0x006d81ae __CFRunLoopRun + 910 | |
19 CoreFoundation 0x006d79d3 CFRunLoopRunSpecific + 467 | |
20 CoreFoundation 0x006d77eb CFRunLoopRunInMode + 123 | |
21 Foundation 0x00105e35 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 284 | |
22 XCTest 0x20119a31 -[XCTestCase(AsynchronousTesting) waitForExpectationsWithTimeout:handler:] + 1192 | |
23 apiTests 0x04008562 -[apiTests setUp] + 482 | |
24 XCTest 0x201088e8 -[XCTestCase invokeTest] + 173 | |
25 XCTest 0x20108bb9 -[XCTestCase performTest:] + 184 | |
26 XCTest 0x20114162 -[XCTest run] + 314 | |
27 XCTest 0x20107598 -[XCTestSuite performTest:] + 406 | |
28 XCTest 0x20114162 -[XCTest run] + 314 | |
29 XCTest 0x20107598 -[XCTestSuite performTest:] + 406 | |
30 XCTest 0x20114162 -[XCTest run] + 314 | |
31 XCTest 0x20107598 -[XCTestSuite performTest:] + 406 | |
32 XCTest 0x20114162 -[XCTest run] + 314 | |
33 XCTest 0x20117929 __24+[XCTestProbe runTests:]_block_invoke189 + 56 | |
34 XCTest 0x20110c82 -[XCTestObservationCenter _observeTestExecutionForBlock:] + 184 | |
35 XCTest 0x201177f7 +[XCTestProbe runTests:] + 371 | |
36 libobjc.A.dylib 0x004be743 +[NSObject performSelector:withObject:] + 70 | |
37 xctest 0x00077237 xctest + 4663 | |
38 xctest 0x000774ac xctest + 5292 | |
39 xctest 0x0007758f xctest + 5519 | |
40 xctest 0x00076e3d xctest + 3645 | |
41 libdyld.dylib 0x017276d9 start + 1 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a library and I have been using GHUnit with it without any problem.
This library basically perform calls to an API and use CoreData to decrease the number of API calls.
Then, I decided to switch to XCTest:
1 - Created the test Target
2 - Created the test class
3 - Runs fine!
Then anything I try to do that involves CoreData I get a error: EXC_BAD_ACCESS(code=EXC_i386_GPFLT)
The same does not happens with GHUnit, it is the same code!
I know that the error is related to trying to access an address that the code is not suppose to, but there's no more details.
I see that in the DatabaseManager the NSString *modelPath = [bundle pathForResource:bundlePath ofType:@"momd"]; returns nil, but, as I said it runs fine when using GHUnit
or simply using the library.
I feel like I am missing some property in the project settings.
Also, it runs if I set the "Host Application".