org.mockito.exceptions.misusing.WrongTypeOfReturnValue

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Scala - Mocking methods that return Value classes
    via by Taylor Smith,
    • org.mockito.exceptions.misusing.WrongTypeOfReturnValue: ValueString cannot be returned by calcValue() calcValue() should return String *** If you're unsure why you're getting above error read on. Due to the nature of the syntax above problem might occur because: 1. This exception *might* occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing. 2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies - [info] - with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method. at com.example.ValueClassSpec$anonfun$1.apply$mcV$sp(testthing.scala:32) at com.example.ValueClassSpec$anonfun$1.apply(testthing.scala:28) at com.example.ValueClassSpec$anonfun$1.apply(testthing.scala:28) at org.scalatest.Transformer$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22) at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85) at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104) at org.scalatest.Transformer.apply(Transformer.scala:22) at org.scalatest.Transformer.apply(Transformer.scala:20) at org.scalatest.FlatSpecLike$anon$1.apply(FlatSpecLike.scala:1647) at org.scalatest.Suite$class.withFixture(Suite.scala:1122)
    No Bugmate found.