Permalink
Browse files

My very first commit 🎉

- basic set up for my challenge goal
- added starting point for first scenario to automate
- adapted readme to my #CodeConfident challenge
  • Loading branch information...
lisihocke committed Jan 15, 2019
1 parent 232466e commit f1c1a5b8cca8e9d797afe8138c3d85cf943d6ad5
@@ -1,36 +1,32 @@
# Serenity Cucumber Starter project
# Serenity & Cucumber Practice Project

[![CircleCI](https://circleci.com/gh/serenity-bdd/serenity-cucumber-starter.svg?style=svg)](https://circleci.com/gh/serenity-bdd/serenity-cucumber-starter)
## #CodeConfident
This repository is the first chosen challenge on [my journey of becoming #CodeConfident](https://www.lisihocke.com/2018/12/a-new-pact-my-challenge-for-2019.html).

## Scope
The scope for this first practice project is to implement 3 scenarios for the test automation practice page http://automationpractice.com using Serenity and Cucumber and applying the Page Object pattern. The focus is on practicing and improving implementation skills, not covering the most risky scenarios.

This is the simplest possible build script setup for Cucumber using Java.
The idea for this project is stolen from/inspired by the Cucumber Java Skeleton project (https://github.com/cucumber/cucumber-java-skeleton).
## How to run the tests

This is a very minimal sample project using Cucumber and Serenity BDD in Java.
You can use this project as a quick starting point for your own projects.

There is a single feature file with one scenario. The scenario has three steps, the last of which is pending.

## Get the code
### Get the code

Git:

git clone https://github.com/serenity-bdd/serenity-cucumber-starter.git
cd serenity-cucumber-starter
git clone https://github.com/lisihocke/serenity-cucumber-practice.git
cd serenity-cucumber-practice

Or simply [download a zip](https://github.com/lisihocke/serenity-cucumber-practice/archive/master.zip) file.

Or simply [download a zip](https://github.com/serenity-bdd/serenity-cucumber-starter/archive/master.zip) file.
### Start up a local Selenium Grid
* Start up a local Selenium Grid with one node.

## Use Maven

Open a command window and run:

mvn clean verify
docker run -d -p 4444:4444 -P --name selenium-hub selenium/hub
docker run -d -e no_proxy=localhost -e HUB_ENV_no_proxy=localhost -e SCREEN_WIDTH=1920 -e SCREEN_HEIGHT=1080 -p 37770:5900 -P --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome-debug

This runs Cucumber features using Cucumber's JUnit runner. The `@RunWith(CucumberWithSerenity.class)` annotation on the `CucumberTestSuite`
class tells JUnit to kick off Cucumber.
* To view the running test, start a VNC tool and go to the defined address `localhost:37770`. The password is `secret`.

## Use Gradle
### Run the tests with Gradle

Open a command window and run:

@@ -39,9 +35,9 @@ Open a command window and run:
This runs Cucumber features using Cucumber's JUnit runner. The `@RunWith(CucumberWithSerenity.class)` annotation on the `CucumberTestSuite`
class tells JUnit to kick off Cucumber.

## Viewing the reports
### Viewing the reports

Both of the commands provided above will produce a Serenity test report in the `target/site/serenity` directory. Go take a look!
The command provided above will produce a Serenity test report in the `target/site/serenity` directory. Go take a look by opening the `index.html`!

## Overriding options

@@ -51,10 +47,6 @@ When you use the JUnit runner, these options are generated from the `@CucumberOp
Sometimes it can be useful to override these options without changing or recompiling the JUnit class. This can be done with the
`cucumber.options` system property. The general form is:

Using Maven:

mvn -Dcucumber.options="..." test

Using Gradle:

gradlew -Dcucumber.options="..." test
@@ -71,7 +63,6 @@ Specify a particular scenario by *line* (and use the pretty plugin, which prints

-Dcucumber.options="classpath:skeleton/belly.feature:4 --plugin pretty"

This works because Maven puts `./src/test/resources` on your `classpath`.
You can also specify files to run by filesystem path:

-Dcucumber.options="src/test/resources/skeleton/belly.feature:4 --plugin pretty"

This file was deleted.

Oops, something went wrong.
163 pom.xml

This file was deleted.

Oops, something went wrong.
@@ -1 +1,9 @@
serenity.project.name=Serenity and Cucumber Quick Start
serenity.project.name=Serenity & Cucumber Practice Project

webdriver.driver=remote
webdriver.remote.url=http://localhost:4444/wd/hub
webdriver.remote.driver=chrome
webdriver.base.url=http://automationpractice.com/

serenity.browser.width=1920
serenity.browser.height=1080

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,9 @@
package pages;

import net.serenitybdd.core.pages.PageObject;
import net.thucydides.core.annotations.NamedUrl;
import net.thucydides.core.annotations.NamedUrls;

@NamedUrls({@NamedUrl(name = "productPage", url = "/index.php?id_product={1}&controller=product")})
public class ProductPage extends PageObject {
}
@@ -3,19 +3,25 @@
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.api.java.en.And;
import pages.ProductPage;

import static net.serenitybdd.core.pages.PageObject.withParameters;

public class StepDefinitions {
@Given("^I am thirsty$")
public void i_am_thirsty() throws Throwable {

ProductPage productPage;

@Given("^I am on a product page$")
public void i_am_on_a_product_page() throws Throwable {
productPage.open("productPage", withParameters("1"));
}

@When("^I order a cappuccino$")
public void i_order_a_cappuccino() throws Throwable {
@When("^I add the item to the cart$")
public void i_add_the_item_to_the_cart() throws Throwable {
}

@Then("^I should not receive a latte$")
public void i_should_not_receive_a_latte() throws Throwable {
@Then("^The cart contains the added item$")
public void the_cart_contains_the_added_item() throws Throwable {
}

}

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,6 @@
Feature: Shopping cart

Scenario: Add item to shopping cart
Given I am on a product page
When I add the item to the cart
Then The cart contains the added item

0 comments on commit f1c1a5b

Please sign in to comment.