title: Thread.sleep is not getting mocked with PowerMockito
body: <p>Here's my setup which is not working:</p>
  <p><strong>SomeclassTest.java</strong></p>
  <pre class="lang-java prettyprint-override"><code>@RunWith(PowerMockRunner.class)
  @PowerMockIgnore(&quot;javax.management.*&quot;)
  @PrepareForTest({SomeclassTest.class, Someclass.class})
  public class SomeclassTest{
  
  @InjectMocks
  private Someclass someclass;
  
  @Test(expected=None.class)
  public void testRun() throws Exception{     
      PowerMockito.mockStatic(Thread.class);
      PowerMockito.doThrow(new RuntimeException()).when(Thread.class);
      Thread.sleep(Matchers.anyLong());        
      try {
              Thread.sleep(5L);
      }catch(Exception ex) {
              System.out.println(&quot;working&quot;); // this is working
      }    
      WhiteboxImpl.invokeMethod(someclass, &quot;run&quot;); // not working in someclass
      PowerMockito.verifyStatic();
  }
  </code></pre>
  <p><strong>Someclass.java</strong></p>
  <pre class="lang-java prettyprint-override"><code>@Named(&quot;Someclass&quot;)
  public class Someclass extends Thread{
  
  @Override
  public void run() {
      while (true) {
          try {
              // clear interruption
              interrupted(); 
              
              long noOfRec= 0;
              if (noOfRec&gt; 0) {
                  Thread.sleep(shortInterval);
              } else {
                  Thread.sleep(longInterval);
              }
          } catch (InterruptedException ex) {
              Thread.currentThread().interrupt(); 
          } catch (Exception ex) {
          }
      }
  }
  </code></pre>
  <p>My issue is PowerMockito isn't mocking <code>Thread.sleep()</code> when it's actually called in <code>Someclass</code> but weirdly working when <code>Thread.sleep()</code> is called inside the JUnit itself.</p>
  <p>I am aware that wrapping <code>Thread.sleep()</code> in another method will solve my issue but I just want to know the correct method of mocking <code>Thread.sleep()</code> with PowerMockito.</p>