Can we follow the below method to initialise the test data? There are 2 points I want to implement.
- Need to initialise/load the test data once from the file and use the same test data in all dataproviders.Thought to implement test data loader in @beforesuite class.
Need data from dataprovider and a parameter from testNG file at the same time in @test method.
@BeforeSuite @Parameters(value = { "test_data_file" }) public static synchronized void init(String test_data_file) { TestDataFactory.load(test_data_file); } @Test(dataProvider="dp_dummy",dataProviderClass = DP_1.class) public void testDummyAPI(TestData test_data,ITestContext context){ String param = context.getCurrentXmlTest().getParameter("param"); } @DataProvider(name = "dp_dummy") public Object[][] getDataFromDataprovider(ITestContext context) { List<TestData> test_data_collection = TestDataFactory.getTestData(targated_test_data); Object[][] test_data_set = new Object[test_data_collection.size()][1]; for(TestData test_data : test_data_collection) test_data_set[i++][0] = test_data; return test_data_set;}