MockedStatic<SpringContextUtils> utils = Mockito.mockStatic(SpringContextUtils.class);
utils.when(() ->SpringContextUtils.publishEvent(any())).thenAnswer(invocation -> null);
maven
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.7.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>3.7.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.7.7</version>
<scope>test</scope>
</dependency>
标签:Mockito,void,mockito,3.7,test,org,utils,mock
From: https://www.cnblogs.com/funkboy/p/17145315.html