From f2c938028068aa196b461fb91cbc9a39bce3bf35 Mon Sep 17 00:00:00 2001 From: kpears201 Date: Tue, 11 Sep 2018 16:13:06 -0700 Subject: [PATCH] Upgrade to net.masterthought:cucumber-reporting:3.2.0 (#45) --- pom.xml | 2 +- .../zucchini/ZucchiniShutdownHook.java | 29 ++++++++++++------- .../zucchini/FastrunZucchiniCukesTest.java | 10 +++---- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index ab5cde0..5e8ce04 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 1.6.4 1.1.2 1.2.4 - 0.0.23 + 3.2.0 6.8.8 diff --git a/src/main/java/com/comcast/zucchini/ZucchiniShutdownHook.java b/src/main/java/com/comcast/zucchini/ZucchiniShutdownHook.java index 5a5f168..db24095 100644 --- a/src/main/java/com/comcast/zucchini/ZucchiniShutdownHook.java +++ b/src/main/java/com/comcast/zucchini/ZucchiniShutdownHook.java @@ -15,27 +15,30 @@ */ package com.comcast.zucchini; -import java.util.List; -import java.util.LinkedList; -import java.util.Properties; - import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.apache.commons.io.FileUtils; +import org.apache.logging.log4j.LogManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.gson.JsonArray; +import net.masterthought.cucumber.Configuration; import net.masterthought.cucumber.ReportBuilder; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import net.masterthought.cucumber.Reportable; class ZucchiniShutdownHook extends Thread { private static final Logger LOGGER = LoggerFactory.getLogger(ZucchiniShutdownHook.class); private static final String NAME_ENV_VAR = "ZUCCHINI_REPORT_NAME"; - + public static final org.apache.logging.log4j.Logger NOOP = LogManager.getLogger(ReportBuilder.class); // Workaround: LogManager needs to be statically initialized outside of a shutdown hook private static ZucchiniShutdownHook instance = null; public static ZucchiniShutdownHook getDefault() { @@ -117,10 +120,14 @@ public void run() { rptName = System.getenv(NAME_ENV_VAR); - ReportBuilder reportBuilder = new ReportBuilder(pathList, html, "", rptName + version, "Zucchini" + version, true, true, true, false, false, "", false); - reportBuilder.generateReports(); + Configuration reportConfig = new Configuration(html, "Zucchini" + version); + reportConfig.setBuildNumber(rptName + version); + ReportBuilder reportBuilder = new ReportBuilder(pathList, reportConfig); + Reportable reportable = reportBuilder.generateReports(); + FileUtils.copyDirectory(new File(html, ReportBuilder.BASE_DIRECTORY), html); // move the cucumber base directory into zucchini + FileUtils.deleteDirectory((new File(html, ReportBuilder.BASE_DIRECTORY))); - boolean buildResult = reportBuilder.getBuildStatus(); + boolean buildResult = (reportable != null) && reportable.getFailedSteps() == 0; if(!buildResult) throw new Exception("BUILD FAILED - Check Report For Details"); } diff --git a/src/test/java/com/comcast/zucchini/FastrunZucchiniCukesTest.java b/src/test/java/com/comcast/zucchini/FastrunZucchiniCukesTest.java index 81f8107..f890b13 100644 --- a/src/test/java/com/comcast/zucchini/FastrunZucchiniCukesTest.java +++ b/src/test/java/com/comcast/zucchini/FastrunZucchiniCukesTest.java @@ -105,12 +105,10 @@ public void cleanup(TestContext out) { public Iterator fastrunIteratorFactory(Iterator iterator) { Iterator response = super.fastrunIteratorFactory(iterator); - if (null == singleton) { - synchronized (this) { - if (null == singleton) { - singleton = response; - wrapped = new TestIterator(response); - } + synchronized (this) { + if (null == singleton) { + singleton = response; + wrapped = new TestIterator(response); } } Assert.assertTrue(singleton == response, "The iterators returned from fastrun should be the same one as it is a singleton");