testNg is ignoring parameterized tests with dataProvider | Maven | IntelliJ

这一生的挚爱 提交于 2019-12-25 08:47:22

问题


I am trying to run a parameterized test in testNg using dataProvider. But somehow it is always ignoring that test case. Below is the reference code:

@DataProvider(name = "test")
public Object[][] testDP() throws Exception {
    Object[][] arrayObject = getExcelData("TestData.xlsx", "TestData", "testName");
    return arrayObject;
}


@Test(dataProvider = "test", groups = {"sanity"})
public void testMethod(String testName, String logisticsHandler) {
    System.out.print(testName + "\n");
    setUpdateLogisticsHandler(logisticsHandler);
    updateLogisticsHandler(context.getAuthToken(),context.getQuoteIdForRfq());

}

回答1:


There are two ways of sending data to the test.

  1. Static Arrays usage - as suggested by Julien Herr
  2. If you are using the excel to get the data then in excel you must have exactly same number of rows/fields as in the @test function.

For Example: String testName, String logisticsHandler are two fields in your @test function then the excel must have ONLY two rows with the required fields testdata so that the ObjectArray will have these fields.

You can use Apache POI and handle this very easily.



来源:https://stackoverflow.com/questions/39595654/testng-is-ignoring-parameterized-tests-with-dataprovider-maven-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!