Code Monkey home page Code Monkey logo

Comments (5)

lukeredpath avatar lukeredpath commented on July 20, 2024

This problem is caused by attempting to intercept messages (spying/stubbing) on objects that are toll-free bridged to their CoreFoundation counterparts. Due to the way that message interception is set up (by creating a custom class at runtime), this cannot be supported.

I've made a change that ensures this fails fast with a descriptive error.

My recommendation would be that you should only ever mock/stub types you own, don't stub/mock native types.

from kiwi.

ma11hew28 avatar ma11hew28 commented on July 20, 2024

Nice... Is stubbing NSString supported by OCMock?

from kiwi.

lukeredpath avatar lukeredpath commented on July 20, 2024

Good question, I haven't tried. If I get a chance I'll look.

Aside from this issue though, my general advice is still to only mock and stub types you own. This is a great book on mock-driven testing - I highly recommend it - and it covers this concept in more detail.

from kiwi.

ma11hew28 avatar ma11hew28 commented on July 20, 2024

Thanks. I'll check that out? In this case, does that guideline still apply since I'm stubbing my own category methods on NSString?

from kiwi.

lukeredpath avatar lukeredpath commented on July 20, 2024

It's borderline, although slightly moot as there is no way currently to stub methods on NSString. I'm curious as to why you are trying to stub your category method; would it not make sense to test it directly? It strikes me that lines 2 and 3 in your spec are redundant.

from kiwi.

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.