问题
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