Mockito: mockStatic is underfined

No matter what I try I get the error "mockStatic(Class<FacesContext>) is undefined for the type TestMainPage". I've tried several differnet combinations of dependencies. I'm using Eclipse and Maven. Here is what the dependency section of my POM currently looks like:

<!-- JUnit for tests -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <!-- Required to mock static methods like FacesContext.getCurrentInstance() -->
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.14.2</version>
            <scope>test</scope>
        </dependency>


Here is my test code:

import javax.faces.context.FacesContext;

import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import static org.mockito.Mockito.*;

public class TestMainPage {

    @Rule
    public MockitoRule rule = MockitoJUnit.rule();

    @Mock
    private FacesContext mockedFacesContext;

    @Test
    public void testView() {
        try (MockedStatic<FacesContext> mockedStaticFacesContext = mockStatic(FacesContext.class)) {
            mockedStaticFacesContext.when(() -> FacesContext.getCurrentInstance()).thenReturn(mockedFacesContext);
            
            ViewBean.run();
        }
    }
}


What am I missing? Could this be an Eclipse issue, a Maven issue, a Build Path issue? What else should I try?
Was this page helpful?