title: TestNG expectedExceptions throws TestException
body: <p>I am trying to test the following class:</p>
  
  <pre><code>package com.myclass;
  public class MyClass {
      private Map&lt;String, String&gt; dataMap = new HashMap&lt;&gt;();
  
      public void extractInfoFromLine(String line) throws InvalidInputException {
          String[] words = line.split(" ");
          if (dataMap.containsKey(words[0])) {
              throw new InvalidInputException();
          }
          dataMap.put(words[0], words[2]);
      }
      public void confirmInfoPresent(String name) {
          // Do something
      }
  }
  </code></pre>
  
  <p>Using this TestNG class:</p>
  
  <pre><code>package com.myclass;
  public class MyClassTest {
      private MyClass myClass;
  
      @DataProvider(name = "invalid-data-provider")
      public Object[][] invalidDataProvider() {
          return new Object[][] { 
                  { "A is B", "A"},
                  { "A is D", "A"},
          };
      }
  
      @BeforeTest()
      public void setup() {
          myClass = new MyClass();
      }
      @Test(dataProvider = "invalid-data-provider", expectedExceptions = InvalidInputException.class)
      public void testExceptionalExtractValueForKey(String line, String name) throws InvalidInputException {
          myClass.extractInfoFromLine(line);
          myClass.confirmInfoPresent(name);
      }
  }
  </code></pre>
  
  <p>I have defined the following custom exception for this:</p>
  
  <pre><code>package com.myclass;
  public class InvalidInputException extends Exception {
      public InvalidInputException() {
          super();
      }
  
      public InvalidInputException(String message) {
          super(message);
      }
  
      public InvalidInputException(String message, Throwable cause) {
          super(message, cause);
      }
  
      public InvalidInputException(Throwable cause) {
          super(cause);
      }
  }
  </code></pre>
  
  <p>However, when I run this test case, I get the following error:</p>
  
  <pre><code>Expected exception com.myclass.InvalidInputException but got org.testng.TestException: 
  Method MyClassTest.testExceptionalExtractValueForKey(java.lang.String, java.lang.String)[pri:0, instance:com.myclass.MyClassTest@3930015a] should have thrown an exception of class com.myclass.InvalidInputException
  </code></pre>
  
  <p>I tried replacing my custom exception with a standard exception and still got the same result.</p>
  
  <p>Can someone please help me with this?</p>