Comments (13)
I've reproduced this problem using the instructions from @lightforce.
Also found another problem that I believe is related. The same error occurs when using dictionaries as arguments in messages to mock object.
@interface Actor : NSObject
- (void)doIt:(NSDictionary *) dict;
@end
@implementation Actor
- (void)doIt:(NSDictionary *) dict {}
@end
@interface SomeTest : SenTestCase
@end
@implementation SomeTest
- (void)testBigTrouble
{
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"value1", @"key1", @"value2", @"key2", nil];
[mock([Actor class]) doIt:dict];
}
@end
This results in an error message like
error: -[SomeTest testBigTrouble] : -[__NSArrayM setObject:atIndexedSubscript:]: unrecognized selector sent to instance 0xa2449b0
from ocmockito.
On that note, almost all of the examples in the README are broken. So... this seems to be a high priority bug.
from ocmockito.
Thank you @codyaray for pointing that out. As for my example it crashes inside MKTInvocationMatcher at line 51, where the new array subscription syntax is used. I think a solution might be to use Clang's _has feature. E.g.
#if __has_feature(objc_array_literals)
// new way.
_argumentMatchers[argumentIndex] = matcher;
#else
// old way (equivalent).
[_argumentMatchers replaceObjectAtIndex:argumentIndex withObject:matcher];
#endif
from ocmockito.
Thanks, you guys. I'll check it out.
from ocmockito.
Any updates?
from ocmockito.
I can't reproduce either problem. But @lightforce you have a clear symptom. What kind of OS / Xcode version are you using that doesn't support new literals?
from ocmockito.
I'm using OCMockito 0.23 downloaded from http://qualitycoding.org/resources/ with XCode 4.3.2 on Mac OS X 10.7.5 and building for iPhone 5.1 Simulator. (Thanks for the TDD tutorial that references OCMockito!) Is there any other information that could help?
from ocmockito.
@codyarray It's odd, but I still can't reproduce. I'm using your Actor / SomeTest sample above, in a Cocoa Touch Static Library project. Could you boil it down to a sample project that you could email to me?
from ocmockito.
Absolutely. I just sent an email with a sample project. Thanks for your help!
from ocmockito.
I configured my testing unit to use OCMockito via Cocoapods
pod 'OCMockito', '~> 0.23'
The Apple LLVM compiler 4.2 is used and the deployment target is iOS 6.1 for both the test bundle and the Pods project. No test host is set for the testing bundle (logic tests). Although I am able to use the new literal syntax inside the test classes without problems, the literals syntax used inside OCMockito makes the tests crash.
from ocmockito.
Okay, so I just upgraded to XCode 4.6 (4H127) through the mac app store and the sample I sent no longer fails. Tested with iPhone 5.1 and 6.1 simulators. Hmm.
from ocmockito.
Though I can't reproduce the problem, I changed the new array use in MKTInvocationMatcher at line 51. @lightforce maybe you could give it a whirl.
from ocmockito.
Works perfectly. Thx!
from ocmockito.
Related Issues (20)
- Swift Static Declaration of 'times' follows non-static declaration HOT 1
- Expected nil, but was nil HOT 3
- Crash when calling mocks from `dealloc` that are not called from elsewhere HOT 16
- MKTArgumentCaptor to HCArgumentCaptor migration HOT 2
- verify macro replaces argument type with id HOT 2
- Unable to @import OCMockitoIOS HOT 4
- Is there a way to assert method throws? HOT 1
- Stubbing the protocol return as Nil HOT 3
- Cannot use OCMockito because of OCHamcrest. HOT 2
- Feature request: possibility to call through HOT 1
- Argument captor capturing outer function HOT 1
- Import OCHamcrest as a module breaks backward compatibility and feels unnecessary HOT 1
- Mock internal calls of a another class methods HOT 4
- Feature Request: Apple Silicon binary release HOT 9
- Catalyst Support for OCMockito.xcframework HOT 8
- verify doesn't fail when parameter is mocked HOT 11
- Stubs return nil when verifying HOT 3
- Could not build OCMockito using Carthage HOT 3
- Building with Carthage fails HOT 1
- Use OCHamcrest 9.0.1 via all dependency managers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocmockito.