Closed rysfa closed 4 years ago
Apologies for the late reply. If this is still current, could you please provide more code from the test? What is it exactly that you are doing with the mock? What does the exception say? Where does the dataWithCPPData:copy:
method come from?
Hi, the issue occurs when I run a test that has OCMClassMock([NSData class])
in it.
By simply running the following test and ensuring that I have All Exceptions breakpoint turned on, I was able to reproduce the exception
- (void)test_exception {
id obj = OCMClassMock([NSData class]);
}
The exception says the following: Thread 1: breakpoint 1.1. Which upon looking more into this exception, it appears to be an internal exception that Cocoa has thrown. I would also like to note, that I do not have any other breakpoints set, other than the All Exceptions breakpoint, and by turning off the All Exceptions breakpoint, this is no longer an issue.
As for where the dataWithCPPData:copy:
selector has come from, it is from. It is the parameter of the following stacktrace call, which was where the exception stopped at:
When this breakpoint has hit, by simply running Continue program execution
, the rest of the test behaves normally, so my current workaround solution to overcome these exceptions being thrown, has been to disable the All Exceptions breakpoint when I run the tests, as these exception do not seem to actually affect the tests, and the tests will behave normally.
Let me know if there are any other information you would like from me.
There must be something else going on. The following test passes for me:
- (void)test_exception {
id obj = OCMClassMock([NSData class]);
OCMStub([obj length]).andReturn(5l);
XCTAssertEqual(5, [obj length]);
}
Hello, I am using OCMock and trying to create a mock object of type, NSData, and run the following line.
id dataMock = OCMClassMock([NSData class])
I have the All Exceptions breakpoint set up, and whenever I tried to run the test, it throws an exception with this stack trace:
The selector that causes this is issue for me is NSData's
dataWithCPPData:copy:
.I have found a similar issue, #107 , that does address the same type of issue that I am seeing here, however with a different data type, and is addressed in the version of OCMock I am running (3.4.3). The main difference between the issue I am seeing and the issue linked, is the data type and the selector in the stack trace that throws the exception.
I am currently using OCMock version 3.4.3 and running Xcode 10.1 on macOS Mojave 10.14.1. I have tested this on iOS 11.4 and 12.1.
Thank you.