NPE guard in test formatter

This commit is contained in:
danikov 2012-03-16 19:21:45 +00:00
parent 2af7272d66
commit 84fe8fa419
1 changed files with 5 additions and 1 deletions

View File

@ -18,6 +18,8 @@
*/
package org.jclouds.vcloud.director.testng;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Set;
@ -104,7 +106,9 @@ public class FormatApiResultsListener implements ITestListener {
}
private String getOperation(ITestResult res) {
return res.getMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class).testName();
Method method = res.getMethod().getConstructorOrMethod().getMethod();
Test test = method.getAnnotation(Test.class);
return test != null ? test.testName() : method.getName();
}
private String getDuration() {