-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock Object not able to stub dynamic properties #218
Comments
The same problem seem to happen with other properties (I'm stubbing It looks like it has something to do with the instance method signature being nil:
returns |
So, if the class cannot provide a method signature, it's somewhat tricky for OCMock to mock the method. What happens when you mock the |
I have just merged #223 which makes it possible to stub dynamic properties as if they were regular methods. Can you verify that this fixes your problem? |
It does not resolve the issue I was facing (on Xcode 7). That issue can very concisely be verified with this test:
Should I file a separate issue for that? |
Yes, I see. The change in #223 only provides the getters while you need the setter. |
I'll update my pod and check later today. seems i found some workaround. |
Sorry for the delay, got busy at work but I'll take a look at this tonight. Mocking the setter should just require synthesizing the method signature in the same way as the getter. |
Assuming fixed. |
I think so given you merged my PRs. |
I'm mocking UILocalNotification.
In its header, it declares :
(line 47, UILocalNotification.h)
@Property(nonatomic,copy) NSDictionary *userInfo; // throws if contains non-property list types
However expecting -userInfo on the UILocalNotification mock throws the "cannot stub/verify .. because it does not exist in the mocked class" exception.
If I do not expect it, when the test runs I get an unrecognized selector exception.
I dont understand why this is happening since it appears to be the same scenario in many tests that work fine.
Here is the test and code under test that reproduces this scenario
https://gist.github.com/jhoughjr/dcfd9a7bbf869c0695d1
Possibly I am doing something wrong, but I don't see it, as this seems a simple test case.
The text was updated successfully, but these errors were encountered: