Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Commit

Permalink
Updated to latest Extent and other few changes (#28)
Browse files Browse the repository at this point in the history
* The following changes are done:
- Fixed scenario outline bugs
- Displaying Examples data table for the scenario outline
- Scenario outline and scenario parent child relationships are maintained properly now
- Introduced Reporter class for fine step logging and screenshot captures

* Updated the travis to use JDK8
  • Loading branch information
email2vimalraj authored Mar 5, 2017
1 parent 835998b commit da8939b
Show file tree
Hide file tree
Showing 14 changed files with 1,160 additions and 359 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: java
jdk:
- openjdk7
- oraclejdk8
notifications:
email:
- [email protected]
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
- sleep 3 # give xvfb some time to start
21 changes: 21 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

### v2.0.0
- Upgraded to the latest version of ExtentReport and made it provided
- Fixed scenario outline bugs
- Displaying Examples data table for the scenario outline
- Scenario outline and scenario parent child relationships are maintained properly now
- Introduced Reporter class for fine step logging and screenshot captures

### v1.1.1
- User now can add test runner log from anywhere. The output will be displayed under the Log tab in the report. Refer the example.
- All the step keywords from cucumber is now displayed.
- Fixed to list the feature tags in the Categories section.

### v1.1.0
- User now can add system information to the report.
- User now can load the extent report config xml to customize the report.
- Fixed the scenario outline, now each scenario in the scenario outline will be properly displayed in the report.

### v1.0.0
- Initial release with basic support of extent report.
135 changes: 49 additions & 86 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,118 +14,81 @@ If you are using a maven based project, you can directly add this library as a d
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>1.1.1</version>
<version>2.0.0</version>
</dependency>
```

Please note that adding the dependency of ExtentReport v3.0.2+ is mandatory.

If not, download the jar from [here](http://search.maven.org/#search%7Cga%7C1%7Ccucumber-extentsreport).

## Release Notes
### v1.1.1
- User now can add test runner log from anywhere. The output will be displayed under the Log tab in the report. Refer the example.
- All the step keywords from cucumber is now displayed.
- Fixed to list the feature tags in the Categories section.
For more details, look at [Changelog](Changelog.md).

### v1.1.0
- User now can add system information to the report.
- User now can load the extent report config xml to customize the report.
- Fixed the scenario outline, now each scenario in the scenario outline will be properly displayed in the report.
## Getting Started

### v1.0.0
- Initial release with basic support of extent report.
### Runner Class example:
Create a runner class and add the `com.cucumber.listener.ExtentCucumberFormatter` as a plugin followed by the report file as input.

## Cucumber runner class
A sample example is show below:

**Example**:
```java
package com.cucumber.runner;

import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.AfterClass;
import org.junit.runner.RunWith;

import java.io.File;

/**
* A sample test to demonstrate
*/
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"com.cucumber.listener.ExtentCucumberFormatter"})
@CucumberOptions(
features = {"src/test/resources/features"},
glue = {"com.cucumber.stepdefinitions"},
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"}
)
public class RunCukesTest {

@BeforeClass
@AfterClass
public static void setup() {
// Initiates the extent report and generates the output in the output/Run_<unique timestamp>/report.html file by default.
ExtentCucumberFormatter.initiateExtentCucumberFormatter();

// Loads the extent config xml to customize on the report.
ExtentCucumberFormatter.loadConfig(new File("src/test/resources/extent-config.xml"));

// User can add the system information as follows
ExtentCucumberFormatter.addSystemInfo("Browser Name", "Firefox");
ExtentCucumberFormatter.addSystemInfo("Browser version", "v31.0");
ExtentCucumberFormatter.addSystemInfo("Selenium version", "v2.53.0");

// Also you can add system information using a hash map
Map systemInfo = new HashMap();
systemInfo.put("Cucumber version", "v1.2.3");
systemInfo.put("Extent Cucumber Reporter version", "v1.1.1");
ExtentCucumberFormatter.addSystemInfo(systemInfo);
Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));
Reporter.setSystemInfo("user", System.getProperty("user.name"));
Reporter.setSystemInfo("os", "Mac OSX");
Reporter.setTestRunnerOutput("Sample test runner output message");
}

}

```

## Initializing report
User can intialize the extent cucumber report in any one of the following ways. Make sure the initialization should happen before your cucumber test start. Ideally, you would be initializing the report in the junit `@BeforeClass` method:
The above example shows a JUnit runner. However, you can use the TestNG runner too.
Also make sure the `loadXMLConfig`, `setSystemInfo` and `setTestRunnerOutput` methods should be in your `@AfterClass` method.

```
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Boolean replaceExisting, DisplayOrder displayOrder, NetworkMode networkMode, Locale locale)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Boolean replaceExisting, DisplayOrder displayOrder, NetworkMode networkMode)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Boolean replaceExisting, DisplayOrder displayOrder, Locale locale)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Boolean replaceExisting, DisplayOrder displayOrder)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Boolean replaceExisting, NetworkMode networkMode, Locale locale)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Boolean replaceExisting, NetworkMode networkMode)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, NetworkMode networkMode)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Boolean replaceExisting, Locale locale)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Boolean replaceExisting)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath, Locale locale)
ExtentCucumberFormatter.initiateExtentCucumberFormatter(File filePath)
ExtentCucumberFormatter.initiateExtentCucumberFormatter()
```
* filePath - path of the file, in .htm or .html format
* replaceExisting - Setting to overwrite (TRUE) the existing file or append to it
* True (default): the file will be replaced with brand new markup, and all existing data will be lost. Use this option to create a brand new report
* False: existing data will remain, new tests will be appended to the existing report. If the the supplied path does not exist, a new file will be created.
* displayOrder
* OLDEST_FIRST (default) - oldest test at the top, newest at the end
* NEWEST_FIRST - newest test at the top, oldest at the end
* networkMode
* ONLINE (default): creates a single report file with all artifacts
* OFFLINE - all report artifacts will be stored locally in %reportFolder%/extentreports and report will be accessible without internet connectivity
* locale - locale of the HTML report, see list of supported locales [here](http://extentreports.relevantcodes.com/java/#localized-versions). To add a localized version of report, create a new .properties file as shown [here](https://github.com/anshooarora/extentreports/blob/master/java/extentreports/src/main/resources/com/relevantcodes/extentreports/view/resources/localized.properties).

## Adding System Information
User can add system information in one of the two ways as follows:
### Logging
User can add logs at any step and those logs will be captured and attached to the corresponding step. The log should be added as follows:

```
ExtentCucumberFormatter.addSystemInfo("BrowserName", "Firefox");
ExtentCucumberFormatter.addSystemInfo("BrowserVersion", "v33.0");
```java
Reporter.addStepLog("Step Log message goes here");
```

or
In case any log to be added at the scenario level, the following can be done:

```
Map systemInfo = new HashMap();
systemInfo.put("Cucumber version", "v1.2.3");
systemInfo.put("Extent Cucumber Reporter version", "v1.1.1");
ExtentCucumberFormatter.addSystemInfo(systemInfo);
```java
Reporter.addScenarioLog("Scenario Log message goes here");
```

## Loading configuration file
Refer here to create the config xml file: [ExtentReports Configuration](http://extentreports.relevantcodes.com/java/#configuration)
To load the config file:
### Adding screenshot / screen cast
The screenshot or screen cast can be added from any of the step as follows:

```
ExtentCucumberFormatter.loadConfig(new File("your config xml file path"));
```java
Reporter.addScreenCaptureFromPath("absolute screenshot path");
Reporter.addScreenCastFromPath("absolute screen cast path");
```

## Add Test Runner Logs
To add the test runner log from any of your step, you can do this:
## Demo
[Report](report.html)

```
@Given("^I am on Google home page$")
public void iAmOnGoogleHomePage() {
open("http://www.google.com");
ExtentCucumberFormatter.setTestRunnerOutput("Your log goes here");
}
```
Fore more details, kindly visit [Cucumber Extent Reporter](http://www.vimalselvam.com/cucumber-extent-reporter/).
18 changes: 7 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>1.1.1</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<name>Cucumber Extents Report</name>
Expand Down Expand Up @@ -45,8 +45,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>1.2.3</cucumber.version>
<extentreports.version>2.41.0</extentreports.version>
<cucumber.version>1.2.5</cucumber.version>
<extentreports.version>3.0.2</extentreports.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -75,18 +75,14 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.relevantcodes</groupId>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>${extentreports.version}</version>
</dependency>

<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.codec</artifactId>
<version>1.8</version>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -165,4 +161,4 @@
</profile>
</profiles>

</project>
</project>
Loading

0 comments on commit da8939b

Please sign in to comment.