title: How do I mock a static method that returns void with PowerMock?
body: <p>I have a few static util methods in my project, some of them just pass or throw an exception. There are a lot of examples out there on how to mock a static method that has a return type other than void. But how can I mock a static method that returns void to just "<code>doNothing()</code>"?</p>
  
  <p>The non-void version uses these lines of codes:</p>
  
  <pre><code>@PrepareForTest(StaticResource.class)
  </code></pre>
  
  <p>...</p>
  
  <pre><code>PowerMockito.mockStatic(StaticResource.class);
  </code></pre>
  
  <p>...</p>
  
  <pre><code>Mockito.when(StaticResource.getResource("string")).thenReturn("string");
  </code></pre>
  
  <p>However if applied to a <code>StaticResources</code> that returns <code>void</code>, the compile will complain that <code>when(T)</code> is not applicable for void... </p>
  
  <p>Any ideas?</p>
  
  <p>A workaround would probably be to just have all static methods return some <code>Boolean</code> for success but I dislike workarounds.</p>