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

Display system information in reports #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private static class ExtentReportsLoader {
"extent.properties",
"com/aventstack/adapter/extent.properties"
};
private static final String SYS_INFO_MARKER = "systeminfo.";
private static final String OUTPUT_PATH = "test-output/";
private static final String EXTENT_REPORTER = "extent.reporter";
private static final String START = "start";
Expand Down Expand Up @@ -140,6 +141,8 @@ private static void createViaProperties() {

if (properties.containsKey(INIT_TABULAR_KEY) && "true".equals(String.valueOf(properties.get(INIT_TABULAR_KEY))))
initTabular(properties);

addSystemInfo(properties);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -173,6 +176,8 @@ private static void createViaSystem() {

if ("true".equals(System.getProperty(INIT_TABULAR_KEY)))
initTabular(null);

addSystemInfo(System.getProperties());
}

private static void initAvent(Properties properties) {
Expand Down Expand Up @@ -263,6 +268,15 @@ private static void attach(ConfigurableReporter r, Properties properties, String
r.loadXMLConfig(String.valueOf(configPath));
INSTANCE.attachReporter(r);
}
}


private static void addSystemInfo(Properties properties) {
properties.forEach((k,v) -> {
String key = String.valueOf(k);
if(key.startsWith(SYS_INFO_MARKER)) {
key = key.substring(key.indexOf('.')+1);
INSTANCE.setSystemInfo(key, String.valueOf(v));
}
});
}
}
}
3 changes: 3 additions & 0 deletions src/test/resources/com/aventstack/adapter/extent.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ extent.reporter.tabular.out=test-output/TabularReport/

screenshot.dir=test-output/
screenshot.rel.path=../

systeminfo.os=Windows
systeminfo.version=10