Giter Club home page Giter Club logo

Comments (4)

erikdoe avatar erikdoe commented on May 12, 2024

I'm not aware of any issues. Are you saying everything compiles cleanly, the test gets invoked, the calls above do not throw any exceptions and still the cacheFolder message doesn't get stubbed? That would be really odd.

from ocmock.

badeleux avatar badeleux commented on May 12, 2024

Ok, I've created example project to visualise this problem. Please clone this repo: https://github.com/badeleux/OCMockPodTest

My output for test method:

2014-02-14 08:27:01.406 OCMockPodTest[2820:70b] TEST STUB: /Volumes/test5M /Volumes/test5M
2014-02-14 08:27:11.008 OCMockPodTest[2820:70b] TEST STUB: /Volumes/test5M ~/Library/Application Support/iPhone Simulator/7.0.3/Applications/7E89CD46-D81B-45E0-96CA-B89C8F1B0383/tmp/Incomplete
2014-02-14 08:27:21.919 OCMockPodTest[2820:70b] TEST STUB: /Volumes/test5M /Volumes/test5M

This demo presents my problem. Stubbing mechanism works for ViewController which is in app target. Moreover stubbed method cacheFolder works in test file (OCMockPodTestTests.m:39 and 41) but no longer works in ViewController.m which is shown in line 40

from ocmock.

carllindberg avatar carllindberg commented on May 12, 2024

I suspect you have include the AFNetworking classes twice in your binary. I think both your library includes libPods.a, meaning it will have a copy of all of those classes. Your test bundle also includes libPods.a, meaning it will have another copy of all those classes. In Xcode 5, it appears that in this situation (rather than duplicate symbol errors), that two versions of each Class get added to the ObjC runtime with the same name. NSClassFromString (which OCMock uses) will only find the first one, probably, and only mock that class. Hard class references in one or the other product will refer to the version of the Class linked with that product -- so your library version will point to the Class linked into your library, whilst your test class code will refer to the one compiled into the test bundle. OCMock will only modify one or the other.

So... try removing libPods.a from the "link binary with libraries" build phase from either your library or the test bundle. They should either be provided bundled inside your library (in which case remove from the test case), or users should be expected to include them along with your library if they are using it, in which case remove libPods from your library target (and the test case, as a consumer of the library, would then need to include it).

from ocmock.

badeleux avatar badeleux commented on May 12, 2024

Right. Thanks!

from ocmock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.