我想知道为什么@parameter({"a,"b"})
中testNG
的语法有这个额外的{}括号。
我对这个主题的研究可能是因为我们必须在这里指定多个数据。
是什么让我认为在参数中使用{}
的原因是不同的是在@Test
我们可以传递像@Test(priority=1, enabled=true)
这样的多个数据,我们在这里不使用{}
in@Test
。
请帮助我理解这一点,无论我的想法是正确的方向还是背后的更多。
括号用于数组/列表。
在TestNG的org.testng.annotations.Parameters中,您可以看到只有一个返回String []的方法声明:
/**
* The list of variables used to fill the parameters of this method.
* These variables must be defined in your testng.xml file.
* For example
* <p>
* <code>
* @Parameters({ "xmlPath" })<br>
* @Test<br>
* public void verifyXmlFile(String path) { ... }<br>
* </code>
* <p>and in <tt>testng.xml</tt>:<p>
* <code>
* <parameter name="xmlPath" value="account.xml" /><br>
* </code>
*/
public String[] value() default {};
相比之下,您可以在testNG的org.testng.annotations.Test中看到,即优先级返回int:
/**
* The scheduling priority. Lower priorities will be scheduled first.
*/
int priority() default 0;