@@ -60,6 +60,8 @@ public void generateReport(
60
60
}
61
61
}
62
62
63
+ final String hostname = getHostName ();
64
+
63
65
for (Map .Entry <Class <?>, Set <ITestResult >> entry : results .entrySet ()) {
64
66
Class <?> cls = entry .getKey ();
65
67
Properties p1 = new Properties ();
@@ -116,10 +118,8 @@ public void generateReport(
116
118
p1 .setProperty (XMLConstants .ATTR_NAME , cls .getName ());
117
119
p1 .setProperty (XMLConstants .ATTR_TESTS , Integer .toString (testCount + ignored ));
118
120
p1 .setProperty (XMLConstants .ATTR_TIME , "" + formatTime (totalTime ));
119
- try {
120
- p1 .setProperty (XMLConstants .ATTR_HOSTNAME , InetAddress .getLocalHost ().getHostName ());
121
- } catch (UnknownHostException e ) {
122
- // ignore
121
+ if (hostname != null ) {
122
+ p1 .setProperty (XMLConstants .ATTR_HOSTNAME , hostname );
123
123
}
124
124
125
125
//
@@ -159,6 +159,15 @@ private static Collection<ITestResult> sort(Set<ITestResult> results) {
159
159
return Collections .unmodifiableList (sortedResults );
160
160
}
161
161
162
+ private static String getHostName () {
163
+ try {
164
+ return InetAddress .getLocalHost ().getHostName ();
165
+ } catch (UnknownHostException e ) {
166
+ // ignore
167
+ return null ;
168
+ }
169
+ }
170
+
162
171
private static int getDisabledTestCount (Set <ITestNGMethod > methods ) {
163
172
int count = 0 ;
164
173
for (ITestNGMethod method : methods ) {
0 commit comments