Dienstag, 25. Juli 2017

Cucumber and Gherkin language in Nederlandse taal

Cucumber has over 60 Languages, which all can bee seen in a Language File .json gherkin-languages.js but be carefull not any cucumber implementation is working in any language whithout problems. As most projects English is the most useful language. But if you do some Language specific application for example a dutch tax calculating software. It might be usefull to use native web

Gherkin example in Nederlandse taal: Stel Als Dann

#language: nl
Functionaliteit: Een broodje Kaas maken
  Om dat ik trek heb 
  Als iemand die graag kaas eet
  Wil ik een broodje kaas eten

  Scenario: Ik mak een broodjke met kaas
    Stel ik heb een broodje
    En ik heb kaas
    Als ik de kaas op de broodje doe
    Dan heb ik een lekker broodje kaas

Gherkin example in Deutsch: Gegeben Wenn Dann

#language: de
Funktionalität: Ein Wurstbrot machen
  Weil ich Hunger habe 
  Als jemand der gerne wurst ist
  Will ich ein Wurstbrot machen

  Szenario: Ich mache ein Wurstbrot
    Gegeben ich habe ein Brot
    Und ich habe Wurst
    Wenn ich die Wurst aufs Brötchen Lege
    Dann habe ich ein Wurstbrot

Gherkin example in English: Given When Then

#language: en
Feature: Make a cup of Tea
  As an English guy
  I wanna drink Tea

  Szenario: I make a cup of tea
    Given i have a hot cup of water 
    And i have some tea
    When i put tea into the hot water
    And remove 5 minutes later
    Then i have tea 

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
}

The 10 best PhoneGap tricks for beginners

These post waiting as a draft for 1 years ... i´ll just publish it now Deploy Early on Real Device - Deploy Automated on Real Device Seeing log Messages http://stackoverflow.com/questions/6854127/filter-logcat-to-get-only-the-messages-from-my-application-in-android adb -d logcat : *:S Deployment Strategie -Seperate web application Use Build tools. Use tools which automatically install dependencies, minimize your code, prepare builds and run tests Bower, Grunt and NPM should be in your standard. Webapp and Phonegap in different repositorys. Automate as much as Possible fast builds does mean fast feedback and fast feedback means you catch errors as early as possible. Deploy fast, use a device use a test player eq B BlueStack it is faster than the usual android emulator. www.bluestacks.com Use a good integrated IDE, we recommend Webstorm. Build your app locally. The remote Build via Phonegap.com is easy for your first up. Uploading each time to build costs a lot of time, local build makes it faster. How to do that ? Install Android SDK or Android Studio C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools Install Gradle https://docs.gradle.org/current/userguide/installation.html set PATH ;%JAVA_HOME%\bin;%GRADLE_HOME%\bin Debugging adb logcat -c adb logcat kann man prima zusehen Problems with Angular $http.post This was my biggest problem cause it breaked the app completely it is a cors cross origin device problem cordova plugin add cordova-plugin-whitelist The Whitelist Plugin is required to avoid cross origin problems Build Tool Default is Gradle but for some reason Phonegap for me used ANT on remote but gradle for locale which caused some problems Use good console - original one is more verbose than intellijs [error] {"error":"Error index.html not found"} [error] Reason 1 HTML Error in index.html could cause this Reason 2 was orginated by existing /build/www directory which could not be deleted. rm -rf (ohh i got this shit linux commands on windows console) helped me to fix it . Wired solution remove and add plattforms