How do I get the name of the test method that was run in a testng tear down method?
Posted
by Zachary Spencer
on Stack Overflow
See other posts from Stack Overflow
or by Zachary Spencer
Published on 2010-06-01T18:20:18Z
Indexed on
2010/06/01
18:33 UTC
Read the original article
Hit count: 171
Basically I have a tear down method that I want to log to the console which test was just run. How would I go about getting that string?
I can get the class name, but I want the actual method that was just executed.
Class testSomething() {
@AfterMethod
public void tearDown() {
system.out.println('The test that just ran was....' + getTestThatJustRanMethodName()');
}
@Test
public void testCase() {
assertTrue(1==1);
}
}
should output to the screen: "The test that just ran was.... testCase"
However I don't know the magic that getTestThatJustRanMethodName should actually be.
© Stack Overflow or respective owner