I am trying to mock a static void method that take a parameter SMTPTools.send(Message)
My deps:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>3.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.6.0</version>
<scope>test</scope>
</dependency>
T try:
try (MockedStatic<SMTPTools> smtpToolsMocked = Mockito.mockStatic(SMTPTools.class)) {
smtpToolsMocked.when((msg) -> SMTPTools.send(msg)).thenAnswer((Answer<Void>) invocation -> null);
}
But it's not even compiling cause
The method when(MockedStatic.Verification) in the type MockedStatic is not applicable for the arguments (( msg) -> {})
But I understand why