How to use testNG @Parameters in @BeforeSuite to read resource file

后端 未结 2 1952
广开言路
广开言路 2021-01-01 08:06

I am using testNG with Selenium webdriver2.0.

In my testNG.xml I have



        
2条回答
  •  Happy的楠姐
    2021-01-01 08:31

    You want to use @Parameter in @BeforeSuite. Suite level parameters are parsed once the suite begins execution and I believe TestNG invokes @BeforeSuite even before the suite is processed:

    Here is a workaround: add ITestContext in method parameters to inject

    @BeforeSuite(groups = { "abstract" } )
    @Parameters({ "configFile" })
    public void initFramework(ITestContext context, String configFile) throws Exception {
    

提交回复
热议问题