kiwi-bdd / Kiwi

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

Unexpected crash in interaction with Google Analytics #637

Closed IndieKevin closed 9 years ago

IndieKevin commented 9 years ago

Tests unexpectedly crash when the Google Analytics CocoaPod is also included alongside Kiwi in the test target.

The error triggers a EXC_BAD_ACCESS in registerMatcherClassesWithNamespacePrefix at this line https://github.com/kiwi-bdd/Kiwi/blob/master/Classes/Core/KWMatcherFactory.m#L76. At the time of error candidateClass is GAITrackedModel.

An example project demonstrating this issue is available here: https://github.com/indiegogo/GoogleAnalyticsKiwiCrash

A discussion of the error is also found here: https://groups.google.com/forum/#!topic/kiwi-bdd/ZfLol8_Oz8k

IndieKevin commented 9 years ago

We've also reported this issue to Google Analytics here: https://code.google.com/p/analytics-issues/issues/detail?id=716&thanks=716&ts=1440021580

coridn commented 9 years ago

I would like to chime in here that I also have this issue, but I do not have Google Analytics in my project. So I do not think this is the tied to GA specifically.

coridn commented 9 years ago

I notice that when this crashes, different classes come up randomly. Here are some of the classes that seem to cause this issue:

From the stack traces, I notice that they all error when + (void)initialize is called.

Also, while trying to run through this to show its not a GA issue, I also randomly seem to get a EXC_BAD_INSTRUCTION error as well. This always happens when running the first spec.

Some additional details that may help. We just recently added Kiwi to our test project. Previously we were writing strictly XCTestCase classes. I notice that the XCTestCases run first. Then the Kiwi specs. If I run JUST the spec I've created alone, the spec works fine. If I attempt to run all other tests as well is when it fails.

yas375 commented 9 years ago

@coridn @IndieKevin I think #649 fixes it. Could you please give it a try?

glentregoning commented 9 years ago

Confirmed #649 fixes the issue, and is a more general solution to the problem. Nice work @yas375

IndieKevin commented 9 years ago

Awesome @yas375! Great clean solution, thanks for the great help and for your investigation. :100:

yas375 commented 9 years ago

I'm glad I can help :)