question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eq and any failing with data classes

See original GitHub issue

Looks like regardless of what data class eq and any has to instantiate, it always fails

java.lang.ClassCastException: org.mockito.Answers cannot be cast to org.mockito.stubbing.Answer

    at com.nhaarman.mockito_kotlin.CreateInstanceKt.uncheckedMock(CreateInstance.kt:162)
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.createNullableInstance(CreateInstance.kt:151)
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.newInstance(CreateInstance.kt:139)
    at com.nhaarman.mockito_kotlin.CreateInstanceKt.createInstance(CreateInstance.kt:60)

Reproduces always with version 0.4.0

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

2reactions
nhaarmancommented, Jun 7, 2016

Let’s reopen this issue for further investigation.

0reactions
nhaarmancommented, Sep 9, 2016

It looks like this issue and #39 are caused by using Mockito 1.x. This library really focuses on the soon-to-be-released 2.x version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

eq and any failing with data classes · Issue #35 - GitHub
Looks like regardless of what data class eq and any has to instantiate, it always fails java.lang.ClassCastException: org.mockito.
Read more >
What's the difference between Mockito Matchers isA, any, eq ...
any() checks absolutely nothing. Since Mockito 2.0, any(T.class) shares isA semantics to mean "any T " or properly "any instance of type T...
Read more >
Eq - Λrrow Core
The Eq typeclass abstracts the ability to compare two instances of any object. It can be considered the typeclass equivalent of Java's Object#equals...
Read more >
This doesn't work - but I think it should, or I'm doing it wrong.
I tried several different things, all failed: ServiceResource aResource = new ServiceResource(); aResource.setID(5); aResource.setData(anyString()); Not enough ...
Read more >
Mockito Argument Matchers - any(), eq() - DigitalOcean
If we want to use a specific value for an argument, then we can use eq() method. when(mockFoo.bool(eq("false"), anyInt(), any(Object.class))).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found