Declare a parameter of type ITestResult in your @AfterMethod and TestNG will inject it:
@AfterMethod
public void afterMethod(ITestResult result) {
System.out.println("method name:" + result.getMethod().getMethodName());
}
More Related Contents:
- How to assign class level data in a TestNG unit test class
- @BeforeClass and inheritance – order of execution
- TestNG: How to test for mandatory exceptions?
- How to write a Unit Test?
- What’s the best mock framework for Java? [closed]
- Final method mocking
- How to tell a Mockito mock object to return something different the next time it is called?
- Get declared fields of java.lang.reflect.Fields in jdk12
- How to run all tests belonging to a certain Category in JUnit 4
- How can I include test classes into Maven jar and execute them?
- Overriding Binding in Guice
- Mockito verify order / sequence of method calls
- mock or stub for chained call
- What are mock objects in Java?
- Selenium web driver: cannot be scrolled into view
- How to prove that HashMap in java is not thread-safe
- JUnit 4: Set up things in a test suite before tests are run (like a test’s @BeforeClass method, just for a test suite)
- How to test a Jersey REST web service?
- Injecting @Autowired private field during testing
- Why are my mocked methods not calld when executing a unit test?
- Jersey – How to mock service
- How can I unit test void functions?
- Java verify void method calls n times with Mockito
- JUnit: new instance before invoking each @Test method. What are the benefits?
- How to launch JUnit 5 (Platform) from the command line (without Maven/Gradle)?
- Can Mockito verify parameters based on their values at the time of method call?
- Using reflection to change static final File.separatorChar for unit testing?
- Easier DynamoDB local testing
- How to disable TestNG test based on a condition
- TestNG parallel Execution with DataProvider