'TestNG test method pass parameter to the BeforeTest method

I'm running in parallele some testNg methods.

On of my needs to that the BeforeTest execute some pre-actions which requires a parameters.

Let's say that I have a set of row with data and each test is a row, but before testing I need to do some actions, so I need to pass to the before test the index of row, it looks like this :

@Test
public void Test() {
test.doTest(0)
}

@Test
public void Test() {
test.doTest(1)
}

@BeforeTest
public void PreTest(index i) {
test.doTest(i)
}

Is there a way to do so ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source