Code Monkey home page Code Monkey logo

Comments (14)

bric3 avatar bric3 commented on May 12, 2024

tough one ;)

from mockito.

MaciejZiarko avatar MaciejZiarko commented on May 12, 2024

Possible duplicate of https://code.google.com/p/mockito/issues/detail?id=303
Solved by https://github.com/cyrusinnovation/mockito-groovy-support

from mockito.

 avatar commented on May 12, 2024

==> Solved by https://github.com/cyrusinnovation/mockito-groovy-support
did not solve my problem. I still have the same error when mocking a groovy class in groovy.

If I mock the groovy class in java I works fine

from mockito.

xnickmx avatar xnickmx commented on May 12, 2024

A very similar problem recently happened to me. I got a NullPointerException in PogoMetaClassSite, where the metaClass was null during a unit test. I was using mockito-groovy-support.

Then I noticed that my mockito-groovy-support depended on Mockito 1.9.5. In my project I was using Mockito 1.8.5. After upgrading my version, everything worked.

from mockito.

bric3 avatar bric3 commented on May 12, 2024

@xnickmx Cool thanks for the feeback

from mockito.

hekonsek avatar hekonsek commented on May 12, 2024

The same here. mockito-groovy-support solved the issue for me, however it would be nice to have the root cause of the issue fixed in Mockito, instead of relaying on the 3rd aprty jar. @moss Can you consider issuing the pull request to Mockito with your fixes? You will make many folks happy ;) .

from mockito.

raphw avatar raphw commented on May 12, 2024

Problem would be that the workarround requires Groovy on the class path. One could avoid this by using reflection. Also, I wonder if there is a better way to check if a method is for retreiving the Groovy meta class than by checking the signature of the method as the current approach would break non-Groovy classes defining a method named getMetaClass.

One could however wire this. I do not think an auto-detection would be difficult to implement.

from mockito.

raphw avatar raphw commented on May 12, 2024

This should do the trick: https://github.com/raphw/mockito/commit/32340365469b99ec5ad2cf2c87b7a79cc472118b

Any objections against this approach?

from mockito.

bric3 avatar bric3 commented on May 12, 2024

I have mixed feelings about these changes, but I must agreed this certainly looks like a simple enough solution. @raphw Make a PR :)

from mockito.

raphw avatar raphw commented on May 12, 2024

Will do tomorrow. Simply ignoring the methods is actually easier.

from mockito.

hekonsek avatar hekonsek commented on May 12, 2024

Many thanks guys!

from mockito.

raphw avatar raphw commented on May 12, 2024

Okay, I pushed a change and put a pull request on the line. Using this, Mockito should support Groovy out of the box.

from mockito.

PascalSchumacher avatar PascalSchumacher commented on May 12, 2024

@raphw I guess this can be closed because Mockito is now using a byte buddy version with your fix?

from mockito.

raphw avatar raphw commented on May 12, 2024

You are right.

from mockito.

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.