kiwi-bdd / Kiwi

Simple BDD for iOS
BSD 3-Clause "New" or "Revised" License
4.14k stars 512 forks source link

KWMocks handled differently in iOS 9+ #657

Closed sbenedicadb closed 8 years ago

sbenedicadb commented 8 years ago

Please consider the following code:

    describe (@"test mocking dictionaries", ^{
        it (@"should handle mocks instead of dictionary parameters", ^{
            NSMutableDictionary *mutableDictionaryMock = [NSMutableDictionary nullMock];
            NSMutableDictionary *aRealDictionary = [NSMutableDictionary dictionaryWithDictionary:mutableDictionaryMock];
        });
    });

This test runs fine on a simulator targeting iOS 8.4, but throws the following error when run against iOS 9.0 or newer:

xctest[58039:9652896] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSDictionary initWithDictionary:copyItems:]: dictionary argument is not an NSDictionary'
sharplet commented 8 years ago

In this case I'd recommend that you don't mock dictionaries. They're value types, and easy enough to create directly. The fact that it's a class cluster further complicates things, too, and could be related to the cause of this change in iOS 9.