Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 778 Bytes

heuristics.adoc

File metadata and controls

24 lines (17 loc) · 778 Bytes

Cucumber Expression - Java Heuristics

Java doesn’t provide a literal syntax for regular expressions, so they have to be specified as strings. Cucumber uses heuristics to determine if a string should be interpreted as a Cucumber Expression or a Regular Expression.

The table below describes the heuristics, along with some examples

Expression Type Explanation

strings are cukexp by default

CucumberExpression

When there are no special characters, a Cucumber Expression is always assumed.

^definitely a regexp$

RegularExpression

The presence of anchors assumes a Regular Expression, even if only one of the anchors are present.

/surely a regexp/

RegularExpression

Forward slashes always assumes Regular Expression. The slashes themselves are removed.