I'm using Spring Boot and in a unit test, I'm trying to mock the Files.delete(myFile.toPath())
method.
To do so I'm trying to use the Mockito.mockStatic()
method. But when I try to use it my IDE (IntelliJ IDEA) indicate me that this method does not exist.
I read this article :
https://asolntsev.github.io/en/2020/07/11/mockito-static-methods/
but it didn't help me.
In my POM.xml file there is:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>3.5.15</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.5.15</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
Note that I only put test related dependency, this is not my whole POM.xml file
In my test file, I put the following imports:
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
Again, this is only the test related imports.
A screenshot of what my IDE is displaying:
Do you have any idea why the Mockito.mockStatic()
method can't be resolved ?