String () { String name = myResult.getTestName(); if (name != null && !name.equals(myResult.getTestClass().getTestName())) { return name; } ITestNGMethod method = myResult.getMethod(); ConstructorOrMethod constructorOrMethod = method.getConstructorOrMethod(); AccessibleObject member = null; if (constructorOrMethod.getMethod() != null) { member = constructorOrMethod.getMethod(); } if (constructorOrMethod.getConstructor() != null) { member = constructorOrMethod.getConstructor(); } if (member == null) return method.getMethodName(); Test annotation = member.getAnnotation(Test.class); if (annotation == null) return method.getMethodName(); String testNameFromAnnotation = annotation.testName(); return testNameFromAnnotation == null || testNameFromAnnotation.isEmpty() ? method.getMethodName() : testNameFromAnnotation; }