Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while mocking #17

Open
obesga-tirant opened this issue Jun 19, 2017 · 3 comments
Open

Error while mocking #17

obesga-tirant opened this issue Jun 19, 2017 · 3 comments

Comments

@obesga-tirant
Copy link

obesga-tirant commented Jun 19, 2017

I can use mockito with groovy only with @CompileStatic classes
I tried to use this library, but everytime I launch the test (compilestatic or not) this error ir thrown

With

compile 'org.codehaus.groovy:groovy-all:2.1.9'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'

Exception

java.lang.AbstractMethodError: com.cyrusinnovation.mockitogroovysupport.GroovyCglibMockMaker.isTypeMockable(Ljava/lang/Class;)Lorg/mockito/plugins/MockMaker$TypeMockability;

    at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:29)
    at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
    at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:186)
    at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:180)
    at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
    at org.mockito.Mockito.mock(Mockito.java:1729)
    at org.mockito.Mockito.mock(Mockito.java:1642)
    at __myclass(__myclass.groovy:57)
@rmchale
Copy link

rmchale commented Jun 30, 2017

Any word on this? I get this with the following

 <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.8.47</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.cyrusinnovation</groupId>
            <artifactId>mockito-groovy-support</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
 <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.8</version>
        </dependency>

@obesga-tirant
Copy link
Author

Sadly, I think this project is out.
And I must admit I have not the time nor the resources to fix it.

:(

There is a 'native' groovy mock feature
http://groovy-lang.org/testing.html#_mockfor_and_stubfor
https://dzone.com/articles/mocking-static-methods-groovy
https://gist.github.com/crazy4groovy/2979077

@dougbacelar
Copy link

dougbacelar commented Jul 3, 2017

This problem was already fixed on newer versions of Mockito.

If you can use the more recent versions of Mockito you do not need this project to make it work with Groovy—it should work out of the box. See mockito/mockito#72 (comment)

I am currently using Mockito 2.8.9 with Groovy 2.4.11 and it works just fine.

Not sure why the following happened to you:

I can use mockito with groovy only with @compilestatic classes

If you post stack trace and how to reproduce the issue, maybe we can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants