1 package test.dataprovider;
2 
3 import org.testng.annotations.DataProvider;
4 import org.testng.annotations.Test;
5 
6 public class IndicesTest {
7 
8   @DataProvider(indices = { 0, 2 })
dp1()9   public Object[][] dp1() {
10     return new Object[][] {
11       new Object[] { 1 },
12       new Object[] { 2 },
13       new Object[] { 3 },
14     };
15   }
16 
17   @Test(dataProvider = "dp1")
indicesShouldWork(int n)18   public void indicesShouldWork(int n) {
19     if (n == 2) throw new RuntimeException("This method should not have received a 1");
20   }
21 }
22