为什么 testng returns 二维对象数组中的数据提供者?

why data provider in testng returns 2D object array?

我最近在做 testNg,但我不知道 return 数据提供者方法中的二维对象数组的设计思想是什么。

从你的问题中我可以了解到,你想知道为什么数据提供者需要二维对象数组。这里我参考了 TestNg 官方文档。请看一下。

https://testng.org/doc/documentation-main.html#parameters-dataproviders

他们提到:

An array of array of objects (Object[][]) where the first dimension's size is the number of times the test method will be invoked and the second dimension size contains an array of objects that must be compatible with the parameter types of the test method

原因很简单,因为我们以行和列的形式获取测试数据,所以我们需要二维对象(对象类型,因为我们可以自由传递任何类型的数据字符串,整数等)数组。

希望对您有所帮助。