Injecting parameters in @BeforeClass method for TestNG

Hi,
I wonder if there's a way to inject parameters to @BeforeClass method when running testng tests. Here's an example of what I mean:


@Parameters({"param1"})
@BeforeClass(alwaysRun = true)
public void init(String param1) throws Exception {
    this.param1 = param1;
}


Something equal to the following in testng config file:

<suite name="Test Suite 1">
    <parameter name="param1"  value="test value"/>
    ...

Thanks,
Ali B

0
1 comment

I found out that those values can be entered in TestNG configuration under Configuration > Parameters tab.

0

Please sign in to leave a comment.