TestNG@Parameters在java上失败,但会传递xml文件!如何解决此问题?

TestNG@Parameters在java上失败,但会传递xml文件!如何解决此问题?,parameters,testng,optional-parameters,Parameters,Testng,Optional Parameters,当我使用XML文件在java代码上运行测试用例时,它是通过的,但当我在eclipse上运行java代码时,它失败了。得到错误说明了这一点 "Parameter 'URL' is required by @Test on method WebloginCarLoan but has not been marked @Optional or defined in c://.... " 原因:通过xml在xml中指定参数,如果直接通过插件运行,则

当我使用XML文件在java代码上运行测试用例时,它是通过的,但当我在eclipse上运行java代码时,它失败了。得到错误说明了这一点

"Parameter 'URL' is required by @Test on method WebloginCarLoan but has not been marked @Optional or defined
in          c://.... "

原因:通过xml在xml中指定参数,如果直接通过插件运行,则无法找到参数,因为它是xml格式的

解决方案您需要将xml设置为模板xml,以使其正常工作。转到项目->属性->测试。将xml设置为模板xml。然后运行您的案例,参数将从xml中选取