Skip to content

Commit

Permalink
Merge pull request testng-team#2802 from spkrka/issue-2801
Browse files Browse the repository at this point in the history
Fix issue 2801 - Only resolve hostname once
  • Loading branch information
juherr authored Sep 14, 2022
2 parents c72d23a + e76ec27 commit 1b978d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Current
New: Ability to provide custom error message for assertThrows\expectThrows methods (Anatolii Yuzhakov)
Fixed: GITHUB-2780: Use SpotBugs instead of abandoned FindBugs
Fixed: GITHUB-2801: JUnitReportReporter is too slow

7.6.1
Fixed: GITHUB-2761: Exception: ERROR java.nio.file.NoSuchFileException: /tmp/testngXmlPathInJar-15086412835569336174 (Krishnan Mahadevan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void generateReport(
}
}

final String hostname = getHostName();

for (Map.Entry<Class<?>, Set<ITestResult>> entry : results.entrySet()) {
Class<?> cls = entry.getKey();
Properties p1 = new Properties();
Expand Down Expand Up @@ -116,10 +118,8 @@ public void generateReport(
p1.setProperty(XMLConstants.ATTR_NAME, cls.getName());
p1.setProperty(XMLConstants.ATTR_TESTS, Integer.toString(testCount + ignored));
p1.setProperty(XMLConstants.ATTR_TIME, "" + formatTime(totalTime));
try {
p1.setProperty(XMLConstants.ATTR_HOSTNAME, InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
// ignore
if (hostname != null) {
p1.setProperty(XMLConstants.ATTR_HOSTNAME, hostname);
}

//
Expand Down Expand Up @@ -159,6 +159,15 @@ private static Collection<ITestResult> sort(Set<ITestResult> results) {
return Collections.unmodifiableList(sortedResults);
}

private static String getHostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
// ignore
return null;
}
}

private static int getDisabledTestCount(Set<ITestNGMethod> methods) {
int count = 0;
for (ITestNGMethod method : methods) {
Expand Down

0 comments on commit 1b978d4

Please sign in to comment.