简体   繁体   中英

TestNG Dataprovider - Filtering test data

I have a TestNG Dataprovider with full of test data. I'm parsing an Excel sheet, so dataprovider has eg. 15 test data list.

I do not want to run my tests with all the 15 test data set, only one. Is it possible to filter the dataset and run the tests with that dataset only? For instance, let's run the test with id1 row. It is just an example, I'm going to store my data as a test object list.

@DataProvider(name = "testCaseSet1")
    public static Object[][] getTestData() {
        return new Object[][] {
                {"id1","testuser1", "test"},
                {"id2","testuser2", "test2"}
        };
    }

一种方法是使用:

@DataProvider(name = "testCaseSet1", indices = {0})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM