Skip to main content
Home
  • Tutorials
    • Quality Assurance
    • Software Development
    • Machine Learning
    • Data Science
  • About Us
  • Contact
programsbuzz facebook programsbuzz twitter programsbuzz linkedin
  • Log in

Main navigation

  • Tutorials
    • Quality Assurance
    • Software Development
    • Machine Learning
    • Data Science
  • About Us
  • Contact

Cucumber Expressions

Profile picture for user devraj
Written by devraj on 09/07/2020 - 04:03

The Cucumber defines its own set of Cucumber Expressions, which are an alternative to Regular expressions. Using Cucumber Expressions, you can use different parameters like int, float, string, etc., inside your step definition expression. You cannot combine Cucumber Expression syntax with Regular Expression syntax in the same expression.

Build-in Parameters type for Cucumber Expressions

Parameter Type Description
{int} Matches integers, for example 10 or -10. Converts to a 32-bit signed integer if the platform supports it.
{biginteger} Matches the same as {int}, but converts to a BigInteger if the platform supports it.
{long} Matches the same as {int}, but converts to a 64 bit signed integer if the platform supports it.
{short} Matches the same as {int}, but converts to a 16 bit signed integer if the platform supports it.
{byte} Matches the same as {int}, but converts to an 8 bit signed integer if the platform supports it.
{float} Matches floats, for example 10.5, .5 or -10.5. Converts to a 32 bit float if the platform supports it.
{bigdecimal} Matches the same as {float}, but converts to a BigDecimal if the platform supports it.
{double} Matches the same as {float}, but converts to a 64 bit float if the platform supports it.
{word} Matches words without whitespace, for example "Hello" not "Hello World"
{string} Matches single-quoted or double-quoted strings, for example "Hello World" or 'Hello World' (but not Hello World). Only the text between the quotes will be extracted. The quotes themselves are discarded. Empty pairs of quotes are valid and will be matched and passed to step code as empty strings.
{} anonymous Matches anything (/.*/).

Using Cucumber Expression in Java Step Definitions

Using Integer

Then count of item is 10

Step Definition

@Then("count of item is {int}")
public void teststep(int n) {
}	

 Using String

Then I should see "Hello World" text

Step Definition

@Then("I should see {string} text")
public void teststep1(String n) {
}
Related Content
Cucumber Java Tutorial
Cucumber Step Definitions Regex Examples
Cucumber Optional Capture Groups
  • Log in or register to post comments

Choose Your Technology

  1. Agile
  2. Apache Groovy
  3. Apache Hadoop
  4. Apache HBase
  5. Apache Spark
  6. Appium
  7. AutoIt
  8. AWS
  9. Behat
  10. Cucumber Java
  11. Cypress
  12. DBMS
  13. Drupal
  14. GitHub
  15. GitLab
  16. GoLang
  17. Gradle
  18. HTML
  19. ISTQB Foundation
  20. Java
  21. JavaScript
  22. JMeter
  23. JUnit
  24. Karate
  25. Kotlin
  26. LoadRunner
  27. matplotlib
  28. MongoDB
  29. MS SQL Server
  30. MySQL
  31. Nightwatch JS
  32. PactumJS
  33. PHP
  34. Playwright
  35. Playwright Java
  36. Playwright Python
  37. Postman
  38. Project Management
  39. Protractor
  40. PyDev
  41. Python
  42. Python NumPy
  43. Python Pandas
  44. Python Seaborn
  45. R Language
  46. REST Assured
  47. Ruby
  48. Selenide
© Copyright By iVagus Services Pvt. Ltd. 2023. All Rights Reserved.

Footer

  • Cookie Policy
  • Privacy Policy
  • Terms of Use