Don't initialize classes when registering matchers #649
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's possible that a library may have some assertions in theirs
+initialize
methods to help developers to find a potential problem in theirs setup. I.e. Facebook SDK makes sure you have specified required url scheme before you use FBSDKAppInviteDialog or FBSDKShareDialog, or FBSDKShareKit/FBSDKMessageDialog.So we've just upgraded to the latest Facebook SDK and have started seeing exceptions when running tests. Those exceptions were exactly in those
+initialize
methods in FB sdk classes. But we don't use those features in our app so we don't need to set up all requirements it asserts for. It works fine when we run our apps because we never call those classes and theirs+initialize
methods never called.When we run tests
KWMatcherFactory#registerMatcherClassesWithNamespacePrefix:
is called and it loops through all available classes and check who conforms toKWMatching
protocol. To check this, it usesNSObject#conformsToProtocol:
which triggers+initialize
call.This doesn't look right. Kiwi doesn't need to trigger
initialize
methods for every class it can see in runtime. The solution is simply to useclass_conformsToProtocol()
function for this.I believe this closes #637, #638, https://groups.google.com/forum/m/#!topic/kiwi-bdd/ZfLol8_Oz8k