From 74437b1213e126a36eba69850fe52ede60a164d4 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 11:27:08 +0800 Subject: [PATCH 01/15] Add Cucumber Extent Reporter to plugin in RunCukesTest --- src/test/java/runners/RunCukesTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/runners/RunCukesTest.java b/src/test/java/runners/RunCukesTest.java index a62654d..3d2b6cc 100644 --- a/src/test/java/runners/RunCukesTest.java +++ b/src/test/java/runners/RunCukesTest.java @@ -1,6 +1,5 @@ package runners; - import org.junit.BeforeClass; import org.junit.runner.RunWith; @@ -11,8 +10,10 @@ @RunWith(Cucumber.class) @CucumberOptions(features = { "src/main/resources/features" }, tags = { "not @ignore" }, glue = { "project.datatable", - "project.hooks", "project.stepdefs" }, plugin = { "pretty", "io.qameta.allure.cucumber3jvm.AllureCucumber3Jvm", - "html:target/cucumber-html-default", "json:target/cucumber-report.json", + "project.hooks", "project.stepdefs" }, plugin = { "pretty", + "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:", + "io.qameta.allure.cucumber3jvm.AllureCucumber3Jvm", "html:target/cucumber-html-default", + "json:target/cucumber-report.json", "junit:target/cucumber-report.xml" }, snippets = SnippetType.UNDERSCORE, monochrome = true, strict = true, dryRun = false) public class RunCukesTest { From 5a138cb6e5c37b04fec3d07427506a9558e49b9f Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 11:33:51 +0800 Subject: [PATCH 02/15] Add extent.properties to src/test/resources --- src/test/resources/extent.properties | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/resources/extent.properties diff --git a/src/test/resources/extent.properties b/src/test/resources/extent.properties new file mode 100644 index 0000000..765a1c3 --- /dev/null +++ b/src/test/resources/extent.properties @@ -0,0 +1,25 @@ +extent.reporter.avent.start=false +extent.reporter.bdd.start=false +extent.reporter.cards.start=false +extent.reporter.email.start=false +extent.reporter.html.start=true +extent.reporter.klov.start=false +extent.reporter.logger.start=true +extent.reporter.tabular.start=false + +extent.reporter.avent.config= +extent.reporter.bdd.config= +extent.reporter.cards.config= +extent.reporter.email.config= +extent.reporter.html.config= +extent.reporter.klov.config= +extent.reporter.logger.config= +extent.reporter.tabular.config= + +extent.reporter.avent.out=test-output/AventReport/ +extent.reporter.bdd.out=test-output/BddReport/ +extent.reporter.cards.out=test-output/CardsReport/ +extent.reporter.email.out=test-output/EmailReport/ExtentEmail.html +extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html +extent.reporter.logger.out=test-output/LoggerReport/ +extent.reporter.tabular.out=test-output/TabularReport/ \ No newline at end of file From 2a0f72c95ffa48819f36bf5aeff16df64c356fb9 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 11:39:54 +0800 Subject: [PATCH 03/15] Configure test-output to target/cucumber-extent-reporter --- src/test/resources/extent.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/resources/extent.properties b/src/test/resources/extent.properties index 765a1c3..644f6e7 100644 --- a/src/test/resources/extent.properties +++ b/src/test/resources/extent.properties @@ -16,10 +16,10 @@ extent.reporter.klov.config= extent.reporter.logger.config= extent.reporter.tabular.config= -extent.reporter.avent.out=test-output/AventReport/ -extent.reporter.bdd.out=test-output/BddReport/ -extent.reporter.cards.out=test-output/CardsReport/ -extent.reporter.email.out=test-output/EmailReport/ExtentEmail.html -extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html -extent.reporter.logger.out=test-output/LoggerReport/ -extent.reporter.tabular.out=test-output/TabularReport/ \ No newline at end of file +extent.reporter.avent.out=target/cucumber-extent-reporter/AventReport/ +extent.reporter.bdd.out=target/cucumber-extent-reporter/BddReport/ +extent.reporter.cards.out=target/cucumber-extent-reporter/CardsReport/ +extent.reporter.email.out=target/cucumber-extent-reporter/EmailReport/ExtentEmail.html +extent.reporter.html.out=target/cucumber-extent-reporter/HtmlReport/ExtentHtml.html +extent.reporter.logger.out=target/cucumber-extent-reporter/LoggerReport/ +extent.reporter.tabular.out=target/cucumber-extent-reporter/TabularReport/ \ No newline at end of file From a3f9fdf19556bd039eac66754d8ff9612dfc7016 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 11:44:20 +0800 Subject: [PATCH 04/15] Add dependency to pom.xml --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index c2d01bc..60b9797 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,13 @@ + + + com.aventstack + extentreports-cucumber3-adapter + 1.0.0 + + org.seleniumhq.selenium From 23068eea653c6396e3d4ea4a04037c2cc7a857e4 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 12:24:56 +0800 Subject: [PATCH 05/15] Refactor pom.xml --- pom.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 60b9797..e0e643c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 com.github.kathyrollo jcucumberng-framework @@ -26,13 +27,6 @@ - - - com.aventstack - extentreports-cucumber3-adapter - 1.0.0 - - org.seleniumhq.selenium @@ -75,6 +69,12 @@ log4j-slf4j-impl 2.11.1 + + + com.aventstack + extentreports-cucumber3-adapter + 1.0.0 + io.qameta.allure From 81e4c28ea61021d89a5df82354ad9facd119ba3d Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 12:55:46 +0800 Subject: [PATCH 06/15] Move extent.properties to src/main/resources --- src/{test => main}/resources/extent.properties | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{test => main}/resources/extent.properties (100%) diff --git a/src/test/resources/extent.properties b/src/main/resources/extent.properties similarity index 100% rename from src/test/resources/extent.properties rename to src/main/resources/extent.properties From 50c36f65288bd6615007e04104d72e29d6918c13 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 13:39:58 +0800 Subject: [PATCH 07/15] Return screenshot filepath in captureScreenshot() --- src/main/java/jcucumberng/api/selenium/Selenium.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/jcucumberng/api/selenium/Selenium.java b/src/main/java/jcucumberng/api/selenium/Selenium.java index 2469cb5..1faf428 100644 --- a/src/main/java/jcucumberng/api/selenium/Selenium.java +++ b/src/main/java/jcucumberng/api/selenium/Selenium.java @@ -340,9 +340,11 @@ public void scrollToElement(WebElement element) { * Captures and saves screenshot in PNG format. Images are stored in * {@code /target/cucumber-sshots/}. * + * @return String - the absolute path to the saved screenshot + * * @throws IOException */ - public void captureScreenshot() throws IOException { + public String captureScreenshot() throws IOException { StringBuilder builder = new StringBuilder(); builder.append(StringUtils.replace(System.getProperty("user.dir"), "\\", "/")); builder.append("/target/cucumber-sshots/sshot_"); @@ -351,13 +353,12 @@ public void captureScreenshot() throws IOException { String screenshot = builder.toString(); File srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(srcFile, new File(screenshot)); + return screenshot; } /** * Captures and embeds screenshot in generated HTML report. Reports can be found * in {@code /target/}. - * - * @param scenario the Scenario object */ public void embedScreenshot() { byte[] srcBytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); From 2cec131e086d048ab495262dde115147e9e57215 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 13:55:43 +0800 Subject: [PATCH 08/15] Update screenshot comments in framework.properties --- src/main/resources/framework.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/framework.properties b/src/main/resources/framework.properties index 72c303b..ea4a903 100644 --- a/src/main/resources/framework.properties +++ b/src/main/resources/framework.properties @@ -14,8 +14,8 @@ wait.for.angular=true screenshot.off=false # Set screenshot options (default = false) -# true - capture screenshot on failure only (after last step) -# false - capture screenshot on every step +# true - capture screenshot on failed scenario (shows screenshot of last step) +# false - capture screenshot after each step screenshot.on.fail=false # Set filename for logger config From 28700e4acb9782d0aa558461887e06b476d9c38b Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 14:21:40 +0800 Subject: [PATCH 09/15] Return byte[] in embedScreenshot() --- src/main/java/jcucumberng/api/selenium/Selenium.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/jcucumberng/api/selenium/Selenium.java b/src/main/java/jcucumberng/api/selenium/Selenium.java index 1faf428..0b47dae 100644 --- a/src/main/java/jcucumberng/api/selenium/Selenium.java +++ b/src/main/java/jcucumberng/api/selenium/Selenium.java @@ -359,10 +359,13 @@ public String captureScreenshot() throws IOException { /** * Captures and embeds screenshot in generated HTML report. Reports can be found * in {@code /target/}. + * + * @return byte[ ] - the screenshot in byte array */ - public void embedScreenshot() { + public byte[] embedScreenshot() { byte[] srcBytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.embed(srcBytes, "image/png"); + return srcBytes; } public WebDriver getDriver() { From a49436a28da6cb825f8da63dd5bd3385f48e5144 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sat, 1 Dec 2018 20:23:35 +0800 Subject: [PATCH 10/15] Update dir to extentreports-cucumber --- src/main/resources/extent.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/extent.properties b/src/main/resources/extent.properties index 644f6e7..7754d35 100644 --- a/src/main/resources/extent.properties +++ b/src/main/resources/extent.properties @@ -16,10 +16,10 @@ extent.reporter.klov.config= extent.reporter.logger.config= extent.reporter.tabular.config= -extent.reporter.avent.out=target/cucumber-extent-reporter/AventReport/ -extent.reporter.bdd.out=target/cucumber-extent-reporter/BddReport/ -extent.reporter.cards.out=target/cucumber-extent-reporter/CardsReport/ -extent.reporter.email.out=target/cucumber-extent-reporter/EmailReport/ExtentEmail.html -extent.reporter.html.out=target/cucumber-extent-reporter/HtmlReport/ExtentHtml.html -extent.reporter.logger.out=target/cucumber-extent-reporter/LoggerReport/ -extent.reporter.tabular.out=target/cucumber-extent-reporter/TabularReport/ \ No newline at end of file +extent.reporter.avent.out=target/extentreports-cucumber/AventReport/ +extent.reporter.bdd.out=target/extentreports-cucumber/BddReport/ +extent.reporter.cards.out=target/extentreports-cucumber/CardsReport/ +extent.reporter.email.out=target/extentreports-cucumber/EmailReport/ExtentEmail.html +extent.reporter.html.out=target/extentreports-cucumber/HtmlReport/ExtentHtml.html +extent.reporter.logger.out=target/extentreports-cucumber/LoggerReport/ +extent.reporter.tabular.out=target/extentreports-cucumber/TabularReport/ \ No newline at end of file From 7b9685ea2735e42a86314213f823125fb1555ad9 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Sun, 2 Dec 2018 02:36:52 +0800 Subject: [PATCH 11/15] Update logpath and rolling filename --- src/main/resources/log4j2.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 89e0d31..52194a3 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -1,8 +1,8 @@ - target/cucumber-logging - cucumber + target/test-logs + jcucumberng From 321dfb0f691f08789f89e0e7189a036a716ed97d Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Mon, 3 Dec 2018 08:44:15 +0800 Subject: [PATCH 12/15] Update README.md --- README.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8ddb2ca..eda0c88 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ In fact, there is no mention of POM in [The Cucumber for Java Book](https://prag > > - Selenium WebDriver + Cucumber + POM = Not OK > -> - Selenium WebDriver + Cucumber + DI = ROI (fast, simple, and lightweight) +> - Selenium WebDriver + Cucumber + DI = ROI (fast, simple, lightweight) [ [Back](#table-of-contents) ] @@ -162,35 +162,42 @@ Generate report into directory: `/target/cucumber-html-reports/` ~~~ mvn verify ~~~ -This is the same task for test execution and report generation. **Output:** ![maven_cucumber_reporting](https://user-images.githubusercontent.com/28589393/44955736-de4d7a80-aeea-11e8-803c-1dced0499fda.gif) -#### [Cucumber Extent Reporter](https://github.com/email2vimalraj/CucumberExtentReporter) -TODO +#### [Cucumber Extent Reports](https://github.com/extent-framework) +> This report is standalone that can be zipped and emailed to clients. Any of the HTML files can be viewed locally using the browser. + +Generate report into directory: `/target/extentreports-cucumber/` +~~~ +mvn verify +~~~ + +**Output:** + #### [Allure Test Report](https://github.com/allure-framework) > This report is a single page application (SPA). Dynamic attributes use AJAX and need to be launched from a [running web server](https://github.com/allure-framework/allure1/issues/896#issuecomment-271599716) to view. -In Allure, test execution and report generation are different tasks. Choose any method to generate the report _after_ running the tests. +Choose any method to generate the report _after_ running the tests. -**Method 1:** Generate report into temp folder and start local web server (opens browser): +**Method 1:** Generate report into temp folder and start local web server (opens browser) ~~~ mvn allure:serve ~~~ -**Method 2:** Generate report into directory: `/target/site/allure-maven-plugin/` +**Method 2:** Generate report in `/target/site/allure-maven-plugin/` ~~~ mvn allure:report ~~~ -Alternatively, the commands can be combined: +**Method 3:** Combine commands ~~~ mvn verify allure:serve ~~~ -This also invokes all reporting plugins. +This also invokes all 3 reporting plugins. **Output:** From 4fb3a57d5161ce19d8396ee9b7147943a0cb0191 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Tue, 4 Dec 2018 10:52:35 +0800 Subject: [PATCH 13/15] Use 1.0.1-SNAPSHOT for extentreports --- pom.xml | 2 +- src/main/resources/extent.properties | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e0e643c..a758a34 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ com.aventstack extentreports-cucumber3-adapter - 1.0.0 + 1.0.1-SNAPSHOT diff --git a/src/main/resources/extent.properties b/src/main/resources/extent.properties index 7754d35..be5ff64 100644 --- a/src/main/resources/extent.properties +++ b/src/main/resources/extent.properties @@ -22,4 +22,6 @@ extent.reporter.cards.out=target/extentreports-cucumber/CardsReport/ extent.reporter.email.out=target/extentreports-cucumber/EmailReport/ExtentEmail.html extent.reporter.html.out=target/extentreports-cucumber/HtmlReport/ExtentHtml.html extent.reporter.logger.out=target/extentreports-cucumber/LoggerReport/ -extent.reporter.tabular.out=target/extentreports-cucumber/TabularReport/ \ No newline at end of file +extent.reporter.tabular.out=target/extentreports-cucumber/TabularReport/ + +screenshot.dir=target/cucumber-sshots \ No newline at end of file From bd62882ba2de716cd6eaef2e498d63e1ba7e6501 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Tue, 4 Dec 2018 11:46:37 +0800 Subject: [PATCH 14/15] Add forward slash to screenshot.dir --- src/main/resources/extent.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/extent.properties b/src/main/resources/extent.properties index be5ff64..aaac761 100644 --- a/src/main/resources/extent.properties +++ b/src/main/resources/extent.properties @@ -24,4 +24,4 @@ extent.reporter.html.out=target/extentreports-cucumber/HtmlReport/ExtentHtml.htm extent.reporter.logger.out=target/extentreports-cucumber/LoggerReport/ extent.reporter.tabular.out=target/extentreports-cucumber/TabularReport/ -screenshot.dir=target/cucumber-sshots \ No newline at end of file +screenshot.dir=target/cucumber-sshots/ \ No newline at end of file From b8bc9a6bdb652fbd3d780a2b46ea586f92950a78 Mon Sep 17 00:00:00 2001 From: Kat Rollo Date: Wed, 5 Dec 2018 20:34:31 +0800 Subject: [PATCH 15/15] Update extentreports-cucumber3-adapter to v1.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a758a34..3e0a552 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ com.aventstack extentreports-cucumber3-adapter - 1.0.1-SNAPSHOT + 1.0.1