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
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

    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