Using Java 8 Features in Cucumber SpecDefinitions

with cucumber java 8 function you have a nice way to use anonymous function for your feature files which makes the old annotations and underscore naming convention obsolete Example code for the ultimate Bowling game .Feature from the Bowling game Kata
  Scenario: Calculating Game Score for utimate Bowling game
    Given I play a 10 rounds Bowling game
    When I bowl a game X X X X X X X X XX X
    Then the game result will be 300 points

Scenario: Calculating Game Score for the worst Bowling game
    Given I play a 10 rounds Bowling game
    When I bowl a game 00 00 00 00 00 00 00 00 00 00
    Then the game result will be 0 points

package bowling;

import cucumber.api.java8.En;
import org.junit.Assert;

public class GameStepDefs implements En {
    private Game game;
    public GameStepDefs() {
        Given("^I play a (\\d+) rounds Bowling game$", (Integer arg0) -> {
            this.game = new Game(10);
        });
        When("^I bowl a game ([0-9, X//]+)$", (String gameString) -> {
            this.game = GameStringReader.createGameFromString(gameString);
        });
        Then("^the game result will be (\\d+) points$", (Integer gameResult) -> {
            Assert.assertEquals(gameResult, this.game.getPoints());
        });

    }
}

Make sure to add the cucumber-java8 plugin to your dependencies in Gradle or other build Tool
dependencies {
    testCompile 'info.cukes:cucumber-java:' + cucumberVersion
    testCompile 'info.cukes:cucumber-java8:' + cucumberVersion
    testCompile 'info.cukes:cucumber-junit:' + cucumberVersion
    testCompile 'junit:junit:' + junitVersion
}

Kommentare

  1. Casinos in the UK - How to find good games - GrizzGo
    So, what 1xbet app do we mean gri-go.com by “casinos novcasino in the UK”? to find a casino and febcasino.com live casino games on a mobile phone device in 2021.

    AntwortenLöschen
  2. All of the beneficial casinos listed here are|listed beneath are} reliable websites that hold gamers secure. They respect playing rules and age restrictions, offering an excellent actual 퍼스트카지노 money gaming experience in a safe setting devoted to gamers' welfare and security online. Wild symbols could be substituted for some other image, to assist a participant make a successful line. These can are available in} a variety of|quite so much of|a big selection of} varieties, together with increasing, shifting, sticky and stacked wilds, all of which behave a unique way|in another way} on the reels. Free video slot games are perfect these who|for many who|for individuals who} are simply looking for a fun way to play slots, whether that be on desktop or cellular gadgets. Not only are they hugely entertaining, they won’t value you a penny to play both.

    AntwortenLöschen

Kommentar veröffentlichen

Beliebte Posts aus diesem Blog

SoCraTes Day Franken 2019

During the final plan review, Program risks are addressed using ROAM. What do the letters in ROAM represent?

An Enterprise has just adopted the SAFe Implementation Roadmap and is in the process of training executives, managers, and leaders. What is their next step?