Version 1
Visibility: Open to anyone

    When a data provider throws an exception, tests that use the data provider are skipped and the exception is not shown in the maven output. By contrary, in the html report, the test are shown as failed.

     

    It occurred creating tests for the project jive-api-tests, using maven 2.2.1 and TestNG 6.8.5

     

    Steps to reproduce

     

    1- Create the data provider:

     

    @DataProvider(name = "exampleDataProvider")
    public static Object[][] exampleDataProvider() throws Exception{
      throw new Exception("I am exampleDataProvider and am throwing an exception.");
    }
    

     

    2- Create a test that uses the data provider:

     

    @Test(groups = {"MyTestGroup"}, dataProvider = "exampleDataProvider", description = "")
    public void testExample(String text) throws Exception {
      Assert.assertTrue(true, "true stop being true");
    }
    

     

    3- Run the tests group "MyTestGroup"

     

    If you look at the output in the console you will see:

    console.jpg

     

    But you can see in the html report:

    Sin nombre.jpg

    One way to to see the exception in the console is creating the following listener:

     

    package package.of.the.listener;
    
    import org.testng.ITestResult;
    import org.testng.TestListenerAdapter;
    
    public class FailListener extends TestListenerAdapter {
      @Override
      public void onTestSkipped(ITestResult tr) {
        tr.setStatus(ITestResult.FAILURE);
      }
    }
    

     

    Then, you can add the listener to your class:

     

    @Listeners({FailListener.class})
    public class ExampleTest extends JiveTest {
      ...
      ...
    

     

    Now, in the console appears:

     

    console - fail.jpg

     

    It is not a fix, but might be useful when programming to have such information in the console. Be aware that you must be careful in how you add the listener, because it fails all the skipped tests of the class.