title: Alternate way to assert Exception thrown from private method in java
body: <p>I need to assert that <code>CustomException</code> is thrown from one of the private utility method <code>doSomething</code><br></p>
  
  <p>This is what I implemented so far and is working.</p>
  
  <p>Define rule at test class level <br><br>
  <code>@Rule
      public ExpectedException exception = ExpectedException.none();</code></p>
  
  <p>Relevant part of test method</p>
  
  <pre><code>exception.expect(CustomException.class);
  // prepare call to executePrivateMethod
  try {
          executePrivateMethod(objInstance, "doSomething",
                  arg0, arg1);
      } catch (InvocationTargetException e) {
          Assert.assertTrue("Invalid exception thrown",
                  (e.getCause() instanceof CustomException));
          throw (CustomException) e.getCause();
      }
  
      Assert.fail("Invalid response");
  </code></pre>
  
  <p><br>I want to know if there is / are alternate  / elegant way available to achieve this? <br><br><strong>P.S.:</strong> <br>1. Very helpful <a href="https://stackoverflow.com/questions/34571/whats-the-proper-way-to-test-a-class-with-private-methods-using-junit">post</a> but no mention of my scenario<br>2. <code>executePrivateMethod</code> uses reflection to invoke private method</p>