ITestResult getTestName() returns null despite of set test name by @Test(testName = “sth”)

纵然是瞬间 提交于 2021-02-19 07:46:26

问题


I set the test name in my test class using annotation: @Test(testName = "sth") and I need to get it from Listener class which implements ITestResult. Method getTestName() returns null but according to http://testng.org/javadocs/org/testng/ITestResult.html#getTestName-- should returns the string.

Am I doing sth wrong? Is it possible to get the string set in @Test(testName = "") from Listener class?


回答1:


getTestName() may return null in some case. Check no regression test from TestNG if you want more details. Depending on your needs, you'll find the 2 other ways to find test names.

Note: Only TestNG versions after 6.9.10 have this behavior.



来源:https://stackoverflow.com/questions/39897855/itestresult-gettestname-returns-null-despite-of-set-test-name-by-testtestnam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!