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

Commit

Permalink
#8 add simple maven cucumber example (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
joergsesterhenn authored and Haroon Sheikh committed Oct 19, 2017
1 parent fbb7e97 commit 78ae19d
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 0 deletions.
55 changes: 55 additions & 0 deletions examples/maven/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sitture</groupId>
<artifactId>cucumber-jvm-extentreport-maven-example</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<description>A maven example for the custom cucumber-jvm formatter using ExtentReports</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<cucumber-jvm-extentreport.version>2.0.3-SNAPSHOT</cucumber-jvm-extentreport.version>
<extentreports.version>3.0.7</extentreports.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<java.version>1.8</java.version>
</properties>

<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>

<dependencies>
<dependency>
<groupId>com.sitture</groupId>
<artifactId>cucumber-jvm-extentreport</artifactId>
<version>${cucumber-jvm-extentreport.version}</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>${extentreports.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
25 changes: 25 additions & 0 deletions examples/maven/src/test/java/com/sitture/RunCukesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.sitture;

import cucumber.api.CucumberOptions;
import cucumber.api.SnippetType;
import cucumber.api.junit.Cucumber;
import org.junit.AfterClass;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/test/resources"},
snippets = SnippetType.CAMELCASE,
plugin = {"com.sitture.ExtentFormatter:target/output/extent-report/index.html", "html:target/output/html-report"}
)
public class RunCukesTest {

@AfterClass
public static void setup() {
ExtentReporter.setConfig("src/test/resources/config.xml");
ExtentReporter.setSystemInfo("Browser", "Chrome");
ExtentReporter.setSystemInfo("Selenium", "v2.53.1");
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.sitture.definitions;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;

public class StepDefinitions {
@Given("^I have (\\d+) cukes in my belly$")
public void iHaveCukesInMyBelly(int cukes) throws Throwable {
System.out.format("Cukes: %d\n", cukes);
}

@Then("^I print out the results$")
public void iPrintOutTheResults() throws Throwable {
// Write code here that turns the phrase above into concrete actions
}

@Given("^I have (\\d+) cukes in my bellies$")
public void iHaveCukesInMyBellies(int cukes) throws Throwable {
System.out.format("Cukes: %d\n", cukes);
}

}
15 changes: 15 additions & 0 deletions examples/maven/src/test/resources/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<extentreports>
<configuration>
<!-- standard, dark -->
<theme>standard</theme>
<!-- defaults to UTF-8 -->
<encoding>UTF-8</encoding>
<!-- title of the document -->
<documentTitle>Test Results</documentTitle>
<reportName>Test Results</reportName>
<reportHeadline> - v1.0.0</reportHeadline>
<!-- defaults to yyyy-MM-dd -->
<dateFormat>dd-MM-yyyy</dateFormat>
</configuration>
</extentreports>
17 changes: 17 additions & 0 deletions examples/maven/src/test/resources/cucumber/feature_one.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@feature_one
Feature: My First Feature

@scenario_one
Scenario Outline: My First Scenario
Given I have <test> cukes in my belly
Then I print out the results

Examples:
| test |
| 1 |
| 2 |

@scenario_two
Scenario: My Second Scenario
Given I have 7 cukes in my bellies
Then I print out the results
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: Second Feature

Scenario: My First Scenario
Given I have 10 cukes in my belly
Then I print out the results

Scenario: My Second Scenario
Given I have 7 cukes in my bellies

0 comments on commit 78ae19d

Please sign in to comment.