TestNG - How to get current class name from BeforeClass.
I have class A with extends class B
class B {
@BeforeClass
public void beforeClass() {
/* Need test class name 'A' */
}
}
class A extends B {
@Test
public void test() {
/* do something */
}
}
In BeforeClass I have tried the only two parameters which inject: ITestContext and XmlTest. However, no luck in determining how to get the class name from either.
Anyone got any ideas? Thanks
Following should do the trick:
@BeforeClass
public void beforeClass() {
String className = this.getClass().getName();
}
How about getClass()
?
(a few more characters to keep SO happy)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With