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.

Google Groups | Taylor Smith | 1 year ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Scala - Mocking methods that return Value classes

    Google Groups | 1 year ago | 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.

    Root Cause Analysis

    1. 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()
    2. com.example
      ValueClassSpec$anonfun$1.apply
      1. com.example.ValueClassSpec$anonfun$1.apply$mcV$sp(testthing.scala:32)
      2. com.example.ValueClassSpec$anonfun$1.apply(testthing.scala:28)
      3. com.example.ValueClassSpec$anonfun$1.apply(testthing.scala:28)
      3 frames
    3. scalatest
      Suite$class.withFixture
      1. org.scalatest.Transformer$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
      2. org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
      3. org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
      4. org.scalatest.Transformer.apply(Transformer.scala:22)
      5. org.scalatest.Transformer.apply(Transformer.scala:20)
      6. org.scalatest.FlatSpecLike$anon$1.apply(FlatSpecLike.scala:1647)
      7. org.scalatest.Suite$class.withFixture(Suite.scala:1122)
      7 frames