org.powermock.api.mockito.ClassNotPreparedException

The class B not prepared for test. To prepare this class, add class to the '@PrepareForTest' annotation. In case if you don't use this annotation, add the annotation on class or method level.

Samebug tips0

We couldn't find tips for this exception.

Don't give up yet. Paste your full stack trace to get a solution.

Solutions on the web5

  • via Stack Overflow by user3789902
    ,
  • via Stack Overflow by Zeyad Gasser
    ,
  • via Stack Overflow by user5483163
    ,
  • Stack trace

    • org.powermock.api.mockito.ClassNotPreparedException: The class B not prepared for test. To prepare this class, add class to the '@PrepareForTest' annotation. In case if you don't use this annotation, add the annotation on class or method level. at org.powermock.api.mockito.expectation.reporter.MockitoPowerMockReporter.classNotPrepared(MockitoPowerMockReporter.java:32) at org.powermock.api.mockito.internal.mockcreation.MockTypeValidatorFactory$DefaultMockTypeValidator.validate(MockTypeValidatorFactory.java:38) at org.powermock.api.mockito.internal.mockcreation.AbstractMockCreator.validateType(AbstractMockCreator.java:10) at org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMock(DefaultMockCreator.java:56) at org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.mock(DefaultMockCreator.java:46) at org.powermock.api.mockito.PowerMockito.mockStatic(PowerMockito.java:71) at Test.testException(Test.java:6) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    osvzsosvzs
    12 times, last one
    Unknown visitor
    Unknown visitorOnce,