testNg忽略了dataProvider |的参数化测试Maven |的IntelliJ [英] testNg is ignoring parameterized tests with dataProvider | Maven | IntelliJ

查看:171
本文介绍了testNg忽略了dataProvider |的参数化测试Maven |的IntelliJ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用dataProvider在testNg中运行参数化测试。但不知何故,它始终忽略了测试用例。以下是参考代码:

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());

}


推荐答案

两种将数据发送到测试的方法。

There are two ways of sending data to the test.


  1. 静态数组的使用 - 如Julien Herr所建议

  2. 如果您使用excel获取数据,那么在excel中,您必须具有与@test函数完全相同的行/字段数。

例如:String testName,String logisticsHandler是@test函数中的两个字段,那么excel必须只有两行,必填字段为testdata,以便ObjectArray将包含这些字段。

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.

您可以使用Apache POI并轻松处理。

You can use Apache POI and handle this very easily.

这篇关于testNg忽略了dataProvider |的参数化测试Maven |的IntelliJ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆