You are on page 1of 7

6015 – Fresco Cucumber Handson

Common Steps for all handson

After launching test, Click on User Online IDE (available at top right corner)

Click on Run → Install, in Web IDE

After installation complete, in terminal type, cd src/test/java/com/play/bdd/runner and press Enter

Type, vi RunPlayTest.java and press Enter

Press I and copy paste the below code

package com.play.bdd.runner;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
format = { "pretty", "html:target/cucumber" },
features = "classpath:cucumber/play.feature"
)
public class RunPlayTest {
}

Then press ESC, then type :wq and press Enter

Then type cd /projects/challenge/src/test/java/com/play/bdd/steps and press Enter

Type, vi PlaySteps.java and press Enter

Press I and copy paste the below code

package com.play.bdd.steps;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class PlaySteps {
@Given("^Play a learning platform$")
public void i_have_a_play() throws Throwable {
//System.out.println("This will print about play");
}
@When("^I want to learn$")
public void love_for_play() throws Throwable {
//System.out.println("This will print love for play");
}
@Then("^I open play to learn and earn$")
public void benefits_of_play() throws Throwable {
//System.out.println("This will print benefits of play");
}
}

Then press ESC, then type :wq and press Enter

Then type, cd /projects/challenge/src/test/resources/cucumber and press Enter

Type play.feature and press Enter

First Cucumber Handson

(cont. from common steps)

Press I and type the below highlighted lines (intendation important and case sensitive)

Feature: First cucumber hands-on

My first Cucumber hands-on.

Scenario: About my learning

Then press ESC, then type :wq and press Enter

Type cd /projects/challenge and press Enter

Type mvn clean test and press Enter

Type tee output.txt and press Enter

Now, click on Run Tests and Submit

Remove the Duplication of Given and Then

(cont. from common steps)

Press I and type the below highlighted lines (intendation important and case sensitive)

Feature: Remove the duplication of Given and Then.

Scenario: Sample scenario to understand Then and remove dubplication.

Given Play is the best learning platform

Given It is fun to learn on Play

When We log in to the play.

Then User should become export.

Then User should get miles and credits.


Then press ESC, then type :wq and press Enter

Type cd /projects/challenge and press Enter

Type mvn clean test and press Enter

Type tee output.txt and press Enter

Now, click on Run Tests and Submit

Add two Numbers

(cont. from common steps)

Press I and type the below highlighted lines (intendation important and case sensitive)

Feature: Calculator hands-on 2 for Cucumber.

As I have passed second hands-on

I need to increase my level

So lets create a calculator program

Scenario: Add two numbers

Given you have a calculator

When you add 3 and 4

The result should be 7

Then press ESC, then type :wq and press Enter

Type cd /projects/challenge/src/main/java/com/play/bdd and press Enter

Type mkdir calculator and press Enter

Type cd calculator and press Enter

Type vi Calculator.java and press Enter

Press I and type the following code

package nl.tudelft.cucumber;

import java.io.Closeable;

public class Calculator implements Closeable {

public int add(int a, int b) {

return a + b;

@Override

public void close() {

// Some hypothetical close function

}
Then press ESC, then type :wq and press Enter

Type cd /projects/challenge and press Enter

Type mvn clean test and press Enter

Type tee output.txt and press Enter

Now, click on Run Tests and Submit

Multiply Two Numbers

(cont. from common steps)

Press I and type the below highlighted lines (intendation important and case sensitive)

Feature: Calculator hands-on 3 for cucumber

As I have passed second hands on

I need to increase my level

Sp lets create a calculator program

Scenario: Multiply two numbers

Given You have a calculator

When you multiply 2 and 4

Then result should come as 8

Then press ESC, then type :wq and press Enter

Type cd /projects/challenge/src/main/java/com/play/bdd and press Enter

Type mkdir calculator and press Enter

Type cd calculator and press Enter

Type vi Calculator.java and press Enter

Press I and type the following code

package nl.tudelft.cucumber;

import java.io.Closeable;

public class Calculator implements Closeable {

public int multiply(int a, int b) {

return a * b;

@Override

public void close() {

// Some hypothetical close function

}
Then press ESC, then type :wq and press Enter

Type cd /projects/challenge and press Enter

Type mvn clean test and press Enter

Type tee output.txt and press Enter

Now, click on Run Tests and Submit

Random Skills

(cont. from common steps)

Press I and type the below highlighted lines (intendation important and case sensitive)

Feature: Random Sting my fourth hand on

I am loving it.

Scenario: Non-capturing group

Given I have a beautiful car

Given I have an attractive car

Given I have a pretty car

Then press ESC, then type :wq and press Enter

Type cd /projects/challenge/src/main/java/com/play/bdd and press Enter

Type mkdir calculator and press Enter

Type cd calculator and press Enter

Type vi Calculator.java and press Enter

Press I and type the following code

package nl.tudelft.cucumber;

import java.io.Closeable;

public class Calculator implements Closeable {

public int add(int a, int b) {

return a + b;

@Override

public void close() {

// Some hypothetical close function

Then press ESC, then type :wq and press Enter


Type cd /projects/challenge and press Enter

Type mvn clean test and press Enter

Type tee output.txt and press Enter

Now, click on Run Tests and Submit

Use this data table to print the value

(cont. from common steps)

Press I and type the below highlighted lines (intendation important and case sensitive)

Feature: Capture the data value for the fifth hands-on

Scenario: Data tables

Given I have the following details for play

| Name | Marks | Percentage |

| Rohan | 320 | 88 |

| Raj | 340 | 90|

| John | 360 | 93|

Then press ESC, then type :wq and press Enter

Type cd /projects/challenge/src/main/java/com/play/bdd and press Enter

Type mkdir calculator and press Enter

Type cd calculator and press Enter

Type vi Calculator.java and press Enter

Press I and type the following code

package nl.tudelft.cucumber;

import java.io.Closeable;

public class Calculator implements Closeable {

public int add(int a, int b) {

return a + b;

@Override

public void close() {

// Some hypothetical close function

Then press ESC, then type :wq and press Enter


Type cd /projects/challenge and press Enter

Type mvn clean test and press Enter

Type tee output.txt and press Enter

Now, click on Run Tests and Submit

You might also like