gpt4 book ai didi

java - TestNG 参数失败

转载 作者:行者123 更新时间:2023-12-01 15:24:08 26 4
gpt4 key购买 nike

初学testng总是添加参数错误

请高手帮忙看看

谢谢!!

java代码:

public class NewTest{

@Parameters({"names"})
@Test
public void test(String name){
System.out.println(name);
}

TestNGxml:

<suite name="Suite" parallel="false">
<parameter name="names" values="aaaaaaaaaa"></parameter>
<test name="Test">
<classes>
<class name="com.test.NewTest"/>
</classes>
</test>
</suite>

异常信息:

org.testng.TestNGException: 
Parameter 'names' is required by @Test on method Test
but has not been marked @Optional or defined
in D:\Documents and Settings\huohui\workspace\lianxi\src\test.xml

最佳答案

也许你应该尝试value="aaaaaaaaaa",而不是values="aaaaaaaaaa"

关于java - TestNG 参数失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10427545/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com