How to Solve Mockito mockedStatic NotAMockException Error

How To Solve Mockito Mockedstatic Notamockexception Error

Error Message:

org.mockito.exceptions.misusing.NotAMockException: Argument handed to Mockito.mockingDetails() needs to be a mock, however is an occasion of sophistication java.lang.Class!
    at org.mockito.inner.runners.StrictRunner.run(StrictRunner.java:52)
    at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:163)
    at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:53)

Solution:
Delete @RunWith(MockitoJUnitRunner.class)
and add

    @Before
    public void earlier than(){
        log.data("start--------{}",this.getClass().getName());
         MockitoAnnotations.openMocks(this);
    }

Read More:

This entry was posted in JAVA and tagged java, junit, Mockito mockedStatic NotAMockException Error, spring on by Robins.

Leave a Reply

Your email address will not be published. Required fields are marked *