Skip test if its data provider provides no data
See original GitHub issueTestNG Version
TestNG version 7.4.0
Expected behavior
Some message should be display so end user can usderstand what is the problem
Actual behavior
I get the blank output
Is the issue reproducible on runner?
[X] TestNG
Test case sample
I try to execute the simple test case which call dataProvider and this dataProvider has return type as Iterator<Object[]>
,i know this return type is not accept by @DataProvider
method but after execute the below program i get the blank output nothing is display in console,i accept at least message like the dataProvider is not exist, please refer below program.
public class Practice {
@Test(dataProvider = "NotWorking")
public void testCase(Object[] obj) {
System.out.println(obj[0]);
System.out.println(obj[1]);
}
@DataProvider(name = "NotWorking")
public Iterator<Object[]> dataProvider2() {
List<Object[]> obj = new ArrayList<Object[]>();
Object[] obj1 = new Object[2];
obj1[0] = new String("First_Object_First_value");
obj1[1] = new String("First_Object_Second_value");
Object[] obj2 = new Object[2];
obj2[0] = new String("Second_Object_First_value");
obj1[1] = new String("Second_Object_Second_value");
Iterator<Object[]> itr = obj.iterator();
return itr;
}
}
i get the below output for above code,
[RemoteTestNG] detected TestNG version 7.4.0
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
Issue Analytics
- State:
- Created 2 years ago
- Comments:11
Top Results From Across the Web
Can I have TestNG fail/skip if the DataProvider provides no ...
The answer is yes...we can check the data provider some tricky we can use it...
Read more >Can I have TestNG fail/skip if the DataProvider provides no ...
If my TestNG DataProvider has some logic in it, but then it results in an empty Object[][] , I would like TestNG to...
Read more >Fail instead of Skip a Test when TestNG's DataProvider throws ...
A quite tricky problem I have been faced with was a failing TestNG-DataProvider which threw an exception because of corrupt test data.
Read more >Skip Exception Test in TestNG - Selenium Easy
In TestNG, @Test(enabled=false) annotation is used to skip a test case if it is not ready to test. We don't need to import...
Read more >Testing in Java & JVM projects - Gradle User Manual
If you don't want to use test class detection, you can disable it by setting the scanForTestClasses property on Test to false ....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s an excellent idea!
@juherr
We have a proper warning message for this, but its the logger that is goofing up things for us. Our customised logger by default sets the log levels for every logger instance to
WARN
(3). And we are logging the problem at an INFO level.https://github.com/cbeust/testng/blob/54329910b9b729b836620aafe926e58cbc4a7dc7/testng-core/src/main/java/org/testng/internal/Parameters.java#L803-L809
So we should be doing a few things here.
I am going to raise a PR which implements (2) and a separate PR which addresses (1)