Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 2801 - Only resolve hostname once #2802

Merged
merged 2 commits into from Sep 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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