Cucumber Lambda expressions

As we all know, jvm-Cucumber has introduced maven dependency for Java 8. With the new API, you can write your step definitions with lambda expressions. It is very easy to setup and creates new step definitions for your feature using Lambda expressions, but understanding Lambda expression is vital.
What is Lambda Expression?
Are you able to create a Java function without a name and belonging to any class? If anyone says “Yes” then it can be done only with Lambda Expression. A lambda expression is an anonymous function and nameless. See the below step definition. The Lambda expression is passed as a parameter in Given method. By introducing Lambda expression in Java 8, Java language has stepped into functional programming.
How to setup?
Step 1: Add Cucumber Java 8 Maven Dependency
Step 2: Add Maven compiler plugin
That’s it.
Step Definition with Lambda Expression

Leave a Reply

Your email address will not be published. Required fields are marked *