TestNG skips the test after raising Exceptions in the @DataProvider method

I am a bit confused.

How can I get TestNG to report an error for a test?

// ... @DataProvider(name = "foo") public Object[][] provideData () { throw new SomeRuntimeException("Some error occurred. The test configuration " + "is somehow incorrect."); } 

This will simply skip the test. An exception is not even logged. Moving this object to the constructor will simply throw an exception, but this is not enough ...

I need a message with a lot of fat.

Currently, using a special (self-testing) method, a task is being performed that at least shows some test failure ...

In any case, it would be nice to know what the definition of testNG error looks like.

Thanks for any tips!

+6
source share
1 answer

Here's an article that offers a fair set of alternatives with reasonably detailed explanations:

Failure to skip a test instead when TestNG DataProvider throws an exception

For me, it's best to add a test for data providers, and here is a quick example:

 public class MyClass { @DataProvider(name = "my-data-provider") private Object [][] myProvider() { // ... } @Test public void testDataProviders() { Assert.assertTrue(myProvider().length > 0); } @Test // ... Real tests. } 
+10
source

Source: https://habr.com/ru/post/969867/


All Articles