有没有一种方法可以为TestNG suite.xml中包含的方法指定参数? [英] Is there a way to specify parameters for included methods in TestNG suite.xml?

查看:251
本文介绍了有没有一种方法可以为TestNG suite.xml中包含的方法指定参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为基于TestNG的自己的testframework编写suite.xml.我的xml文件如下所示:

I'm writing a suite.xml for an own testframework based on TestNG. My xml file looks like:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite" parallel="methods">
  <test name="NewTest">
  <parameter name="BROWSER" value="Chrome"></parameter>
  <classes>
   <class name="hm.NewTest">
     <methods>
        <include name="test"></include>
        <include name="test2"></include>
        <include name="test3"></include>
        <include name="test4"></include>
     </methods>
   </class>
 </classes>
 </test>
 </suite>

现在为完整测试指定了参数"BROWSER".但是,对于每个包含的方法,我都需要一个自己的参数.有人知道解决方案吗?

The parameter "BROWSER" is now specified for the complete test. But i need an own parameter for each of the included methods. Does anyone knows a solution?

推荐答案

为此,您可以为测试单独分配参数,而不是在测试套件xml中分配参数.为此,您不必在suite.xml中添加每个参数.

For this rather than assigning parameters in test suite xml you can assign parameters for your tests individually . for that you don't have to add each parameter in suite.xml .

@Parameters({ "datasource", "jdbcDriver" })
@test
public void sampleTest(String ds, String driver) {
// your test method
}

希望这会对您有所帮助 1

Hope this will help you 1

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

这篇关于有没有一种方法可以为TestNG suite.xml中包含的方法指定参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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