org.mockito.exceptions.misusing.WrongTypeOfReturnValue: NestedWhen$Product$$EnhancerByMockitoWithCGLIB$$6ecf83da cannot be returned by getBar() getBar() should return Bar *** This exception *might* occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing.

Google Groups | ludyte | 5 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    WrongTypeOfReturnValue when nesting when().thenReturn

    Google Groups | 5 years ago | ludyte
    org.mockito.exceptions.misusing.WrongTypeOfReturnValue: NestedWhen$Product$$EnhancerByMockitoWithCGLIB$$6ecf83da cannot be returned by getBar() getBar() should return Bar *** This exception *might* occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing.

    Root Cause Analysis

    1. org.mockito.exceptions.misusing.WrongTypeOfReturnValue

      NestedWhen$Product$$EnhancerByMockitoWithCGLIB$$6ecf83da cannot be returned by getBar() getBar() should return Bar *** This exception *might* occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing.

      at NestedWhen.nestedWhenTest()
    2. Unknown
      NestedWhen.nestedWhenTest
      1. NestedWhen.nestedWhenTest(NestedWhen.java:36)
      1 frame
    3. Java RT
      NativeMethodAccessorImpl.invoke0
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      1 frame