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

Merge develop into master #139

Merged
merged 16 commits into from
Dec 5, 2018
Merged
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
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) ]

Expand Down Expand Up @@ -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:**

Expand Down
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.kathyrollo</groupId>
<artifactId>jcucumberng-framework</artifactId>
Expand Down Expand Up @@ -68,6 +69,12 @@
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports-cucumber3-adapter -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports-cucumber3-adapter</artifactId>
<version>1.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-cucumber3-jvm -->
<dependency>
<groupId>io.qameta.allure</groupId>
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/jcucumberng/api/selenium/Selenium.java
Original file line number Diff line number Diff line change
Expand Up @@ -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_");
Expand All @@ -351,17 +353,19 @@ 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
* @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() {
Expand Down
27 changes: 27 additions & 0 deletions src/main/resources/extent.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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=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/

screenshot.dir=target/cucumber-sshots/
4 changes: 2 additions & 2 deletions src/main/resources/framework.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="logPath">target/cucumber-logging</Property>
<Property name="rollingFileName">cucumber</Property>
<Property name="logPath">target/test-logs</Property>
<Property name="rollingFileName">jcucumberng</Property>
</Properties>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/runners/RunCukesTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package runners;


import org.junit.BeforeClass;
import org.junit.runner.RunWith;

Expand All @@ -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 {
Expand Down