1package test.dataprovider;
2
3import org.testng.annotations.DataProvider;
4import org.testng.annotations.Test;
5
6import java.util.Iterator;
7
8public class FailingIterableDataProvider {
9
10  @DataProvider(name = "dp")
11  public Iterator<Object[]> createData() {
12    return new Iterator<Object[]>() {
13    int count=0;
14
15    @Override
16    public boolean hasNext() {
17      return count<10;
18    }
19
20    @Override
21    public Object[] next() {
22      if (++count==6) {
23        throw new RuntimeException();
24      }
25      return new Object[] { count };
26    }
27
28    @Override
29    public void remove() {}
30
31    };
32  }
33
34  @Test(dataProvider="dp")
35  public void happyTest(int count) {
36    //pass
37  }
38}
39