小编DnD*_*DnD的帖子

如何在@BeforeSuite中使用testNG @Parameters来读取资源文件

我使用testNGSelenium webdriver2.0.

在我的testNG.xml

<suite data-provider-thread-count="2" name="selenium FrontEnd Test" parallel="false" skipfailedinvocationCounts="false" thread-count="2">
  <parameter name="config_file" value="src/test/resources/config.properties/"/>
  <test annotations="JDK" junit="false" name="CarInsurance Sanity Test" skipfailedinvocationCounts="false" verbose="2">
    <parameter name="config-file" value="src/test/resources/config.properties/"/>
    <groups>
      <run>
        <include name="abstract"/>
        <include name="Sanity"/>
      </run>
    </groups>
    <classes>
    </classes>
  </test> 
</suite>
Run Code Online (Sandbox Code Playgroud)

在java文件中

@BeforeSuite(groups = { "abstract" } )
@Parameters(value = { "config-file" })
public void initFramework(String configfile) throws Exception 
{
    Reporter.log("Invoked init Method \n",true);

    Properties p = new Properties();
    FileInputStream  conf = new FileInputStream(configfile);
    p.load(conf);

    siteurl = p.getProperty("BASEURL"); …
Run Code Online (Sandbox Code Playgroud)

java testng

1
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×1

testng ×1