Comments (14)
tough one ;)
from mockito.
Possible duplicate of https://code.google.com/p/mockito/issues/detail?id=303
Solved by https://github.com/cyrusinnovation/mockito-groovy-support
from mockito.
==> 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.
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.
@xnickmx Cool thanks for the feeback
from mockito.
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.
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.
This should do the trick: https://github.com/raphw/mockito/commit/32340365469b99ec5ad2cf2c87b7a79cc472118b
Any objections against this approach?
from mockito.
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.
Will do tomorrow. Simply ignoring the methods is actually easier.
from mockito.
Many thanks guys!
from mockito.
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.
@raphw I guess this can be closed because Mockito is now using a byte buddy version with your fix?
from mockito.
You are right.
from mockito.
Related Issues (20)
- MockSettings.strictness() not observed HOT 2
- Mockito verify message not accurate if type is fields are of Object
- when does not throw MissingMethodInvocationException HOT 1
- Spy annotation does not seem to work after switching from Mockito 4.8.1 to 5.10.0 HOT 1
- `mockStatic` fails with `class redefinition failed: invalid class` HOT 5
- mockito
- Field with generics is not injected using @InjectMocks HOT 1
- Possible race condition HOT 3
- MissingMethodInvocationException is thrown when mocking native method in 5.x HOT 1
- ByteBuddy agent fails to install on GraalVM HOT 1
- Incorrect documentation for RETURNS_MOCKS HOT 3
- Mockito.only() points to the wanted call as unwanted if it is the first being called.
- Mockito vs EasyMock performance HOT 4
- @Mock and MockedConstruction
- application HOT 1
- In TypeBasedCandidateFilter.isCompatibleTypes -> ClassCastException: class TypeVariableImpl cannot be cast to class Class HOT 9
- Spy does not see method called in feedback call HOT 3
- Mockito.mock(...) does not work inside an Arquillian integration test anymore HOT 1
- Feature Request: MockedConstruction needs a setInitializer method
- ArgumentMatcher like assertArg() for multiple different calls? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mockito.