Injecting parameters in @BeforeClass method for TestNG

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:

@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"/>

Ali B

1 comment

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


Please sign in to leave a comment.