Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cristiankocza-sv
Copy link

Objective-c's default return type is id. Currently Kiwi generates method signatures with the "void" return type if the stubbed method is not found within the mocked class/protocol.

@supermarin
Copy link

just wondering, do you think it would make sense to write a test for this one?
or to put it the other way - what was the actual problem that caused you to write this patch? :)

@cristiankocza-sv
Copy link
Author

I added a unit test for this. The scenario that lead me to the changes in this PR is the following:

  • have the test object make use of a CustomClass object
  • create a mock for the CustomProtocol protocol
  • stub one of the methods from CustomClass that is known to be called from the test object, and have it return an object
  • the unit test will crash due to forwardInvocation: trying to set the invocation return data, while the the invocation has a return length of zero

This also happens if I try to mock a class that implements several protocols, as the KWMock constructor allows either a class, or a single protocol.

supermarin added a commit that referenced this pull request Oct 18, 2013
Using the objective-c default return type id instead of void for stubbed methods
@supermarin supermarin merged commit ed3c084 into kiwi-bdd:master Oct 18, 2013
@supermarin
Copy link

@cristiankocza nicely done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants