From c3ba3000562f2d6b87be1a5c222c07c419924f4c Mon Sep 17 00:00:00 2001 From: VimalRaj Selvam Date: Fri, 10 Mar 2017 07:45:39 +0530 Subject: [PATCH] Fixed the system info when execute from multiple runners (#30) --- Changelog.md | 3 +++ pom.xml | 2 +- src/main/java/com/cucumber/listener/Reporter.java | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index b7da139..26c2ffa 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +### v2.0.2 +- Fixed the system info when execute from multiple runners + ### v2.0.1 - Added a feature to display the data table in the step - Fixed the thread safe issue when run in parallel diff --git a/pom.xml b/pom.xml index 8f0a158..184d27b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.vimalselvam cucumber-extentsreport - 2.0.1 + 2.0.2 jar Cucumber Extents Report diff --git a/src/main/java/com/cucumber/listener/Reporter.java b/src/main/java/com/cucumber/listener/Reporter.java index a88309c..9fbb8ac 100644 --- a/src/main/java/com/cucumber/listener/Reporter.java +++ b/src/main/java/com/cucumber/listener/Reporter.java @@ -6,12 +6,15 @@ import java.io.File; import java.io.IOException; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * This class houses few utilities required for the report */ public class Reporter { + private static Map systemInfoKeyMap = new HashMap(); private Reporter() { // Defeat instantiation @@ -104,15 +107,24 @@ public static void addScreenCast(String screenCastPath) throws IOException { /** * Sets the system information with the given key value pair - * @param key The name of the key + * + * @param key The name of the key * @param value The value of the given key */ public static void setSystemInfo(String key, String value) { + if (systemInfoKeyMap.isEmpty() || !systemInfoKeyMap.containsKey(key)) { + systemInfoKeyMap.put(key, false); + } + if (systemInfoKeyMap.get(key)) { + return; + } getExtentReport().setSystemInfo(key, value); + systemInfoKeyMap.put(key, true); } /** * Sets the test runner output with the given list of strings + * * @param log The list of string messages */ public static void setTestRunnerOutput(List log) { @@ -121,6 +133,7 @@ public static void setTestRunnerOutput(List log) { /** * Sets the test runner output with the given string + * * @param outputMessage The message to be shown in the test runner output screen */ public static void setTestRunnerOutput(String outputMessage) {