org.mockito.exceptions.base.MockitoException: Unable to initialize @Spy annotated field 'a'. null

GitHub | bric3 | 2 months 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

    @Spy dosn't report the correct error when it can't instantiate abstract class

    GitHub | 2 months ago | bric3
    org.mockito.exceptions.base.MockitoException: Unable to initialize @Spy annotated field 'a'. null
  2. 0

    2.0.8-beta -> 2.0.9-beta 'Unable to initialize @Spy annotated field

    GitHub | 2 years ago | brcolow
    org.mockito.exceptions.base.MockitoException: Unable to initialize @Spy annotated field 'monitorTaskScheduler'. Unable to create mock instance of type 'MonitorTaskScheduler'
  3. 0

    Can't mock Charset

    Google Groups | 5 years ago | David Wallace
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Problems with Mockito 2.x on OSGi container Equinox

    Google Groups | 1 month ago | Nick Stolwijk
    java.lang.NoClassDefFoundError: Could not initialize class nl.a.b.c.projectbeheer.Project$MockitoMock$735984955
  6. 0

    Supports discussion among AspectJ users and developers on topics such as language design, new features, and best usage practices

    gmane.org | 1 year ago
    org.mockito.exceptions.base.MockitoException: >>>>> Mockito cannot mock this class: class org.sample.SamplelTest$1 >>>>> Mockito can only mock visible & non-final classes. >>>>> If you're not sure why you're getting this error, please report to >>>>> the mailing list. >>>>> ... 25 more >>>>> Caused by: org.mockito.cglib.core.CodeGenerationException: >>>>> java.lang.reflect.InvocationTargetException-->null >>>>> at >>>>> org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:238) >>>>> at >>>>> org.mockito.cglib.proxy.Enhancer.createHelper(Enhancer.java:378) >>>>> at >>>>> org.mockito.cglib.proxy.Enhancer.createClass(Enhancer.java:318) >>>>> at >>>>> org.mockito.internal.creation.cglib.ClassImposterizer.createProxyClass(ClassImposterizer.java:123) >>>>> at >>>>> org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:57) >>>>> at >>>>> org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:49) >>>>> at >>>>> org.mockito.internal.creation.cglib.CglibMockMaker.createMock(CglibMockMaker.java:24) >>>>> at >>>>> org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33) >>>>> at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59) >>>>> at org.mockito.Mockito.mock(Mockito.java:1285) >>>>> at >>>>> org.mockito.internal.configuration.injection.SpyOnInjectedFieldsHandler.processInjection(SpyOnInjectedFieldsHandler.java:43) >>>>> at >>>>> org.mockito.internal.configuration.injection.MockInjectionStrategy.process(MockInjectionStrategy.java:68) >>>>> at >>>>> org.mockito.internal.configuration.injection.MockInjectionStrategy.relayProcessToNextStrategy(MockInjectionStrategy.java:89) >>>>> at >>>>> org.mockito.internal.configuration.injection.MockInjectionStrategy.process(MockInjectionStrategy.java:71) >>>>> at >>>>> org.mockito.internal.configuration.injection.MockInjection$OngoingMockInjection.apply(MockInjection.java:93) >>>>> at >>>>> org.mockito.internal.configuration.DefaultInjectionEngine.injectMocksOnFields(DefaultInjectionEngine.java:20) >>>>> at >>>>> org.mockito.internal.configuration.InjectingAnnotationEngine.injectMocks(InjectingAnnotationEngine.java:100) >>>>> at >>>>> org.mockito.internal.configuration.InjectingAnnotationEngine.processInjectMocks(InjectingAnnotationEngine.java:62) >>>>> at >>>>> org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:56) >>>>> at >>>>> org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:108) >>>>> ... 25 more >>>>> Caused by: java.lang.reflect.InvocationTargetException >>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.mockito.exceptions.base.MockitoException

      Unable to initialize @Spy annotated field 'a'. null

      at org.mockito.internal.configuration.SpyAnnotationEngine.process()
    2. Mockito
      InjectingAnnotationEngine.process
      1. org.mockito.internal.configuration.SpyAnnotationEngine.process(SpyAnnotationEngine.java:70)
      2. org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:59)
      3. org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
      3 frames