I am invoking TestNG programmaticaly. I use Data Providers to pass values to test method. Is there any way if I can pass a parameter to @BeforeClass and @AfterClass methods?
You can try @Parameters for @BeforeMethod if that helps.
I was also looking for the same but I tried to pass parameters to @BeforeMethod
, @BeforeClass
, @BeforeSuite
and @Test
methods and observed that it works for all except @BeforeClass
but when I tried with @BeforeClass
, no error is thrown.
Instead of going for @BeforeClass
, you can pass parameters to @BeforeSuite
which might help you to achieve your goal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.