Test installation went abnormally with code 134 with OCMock check on iOS 4

I'm trying to add OCMock to my iOS 4 project. To test this, I have a Person class with one method, -hello . When I run this test:

 - (void) testMock { id mock = [OCMockObject mockForClass:[Person class]]; [[mock expect] hello]; [mock hello]; [mock verify]; } 

Everything is in order, and the assembly is completed successfully. If I pick up the hello call, for example:

 - (void) testMock { id mock = [OCMockObject mockForClass:[Person class]]; [[mock expect] hello]; [mock verify]; } 

I expect to receive an error message informing me that my expected method was not called in mock. Instead, I get a cryptic test setup failure message:

 /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). 

Is this failure normal when the expected method is not called? Am I having a bad configuration?

+3
source share
4 answers

You don't have a bad configuration, this is a bug that Apple introduced in the simulator SDK when they released iOS4. Basically, if code called using the NSInvocation object throws an exception, then this exception is not possible. I wrote about the problem when it first appeared here:

http://pivotallabs.com/users/adam/blog/articles/1302-objective-c-exceptions-thrown-inside-methods-invoked-via-nsinvocation-are-uncatchable

Unfortunately, this error affects OCMock, and Apple does not show much interest in fixing it. Many people have submitted bug reports, but to no avail.

I understand that this is of little comfort, but you will get somewhat better error messages when using Cedar for testing (I believe this is true for GTM ).

+4
source

I would say that this is a mistake. Verify should report a useful result, even if it fails.

+2
source

I found that this error still exists with Xcode 4 / SDK 4.3 in April 2011. For example, test A passes, test B resets the test setup.

Test A:

 - (void)testAcceptsAndVerifiesExpectedMethods { id mock = [OCMockObject mockForClass:[NSString class]]; [[mock expect] lowercaseString]; [mock lowercaseString]; [mock verify]; } 

Test B:

 - (void)testAcceptsAndVerifiesExpectedMethods { id mock = [OCMockObject mockForClass:[NSString class]]; [[mock expect] lowercaseString]; //[mock lowercaseString]; [mock verify]; } 
+2
source

The workaround I found is to wrap the calls to [mockObject expect] and [mockObject verify] with XCTAssertNoThrow, for example:

 XCTAssertNoThrow([[mockTaskVC expect] showAlertWithTitle:containsString(@"Error") message:OCMOCK_ANY completion:OCMOCK_ANY], @"threw up exception"); 

This will cause the exception to crash and the text to crash, not the crash.

Credit to the author here: http://www.mulle-kybernetik.com/forum/viewtopic.php?f=4&t=315&p=710&hilit=unexpected+method+was+not+invoked+exception#p710

0
source

All Articles