Class GlueCodeScanner
java.lang.Object
com.arc_e_tect.gradle.gherkin.glue.GlueCodeScanner
Scans a directory of Cucumber-JVM glue code (step definition source files) and
extracts every
@Given/@When/@Then step definition pattern
as a compiled Expression.
Step definitions are matched with a regular expression over the raw source text
rather than a full Java/Kotlin parser, since only the string literal passed to the
annotation is needed. Both Cucumber Expressions and regular-expression step patterns
are supported, since ExpressionFactory auto-detects which kind a given
pattern is.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<io.cucumber.cucumberexpressions.Expression> Recursively scansglueCodeDirfor step definition source files and returns every step pattern found as a compiledExpression.List<io.cucumber.cucumberexpressions.Expression> Same asscan(File), additionally invokingonFileScannedonce for every source file it processes - whether or not that file contains any step definitions - so a caller can drive a progress indicator during what would otherwise be a single opaque, potentially long-running call across a whole directory tree.
-
Constructor Details
-
GlueCodeScanner
public GlueCodeScanner()Creates a newGlueCodeScanner.
-
-
Method Details
-
scan
Recursively scansglueCodeDirfor step definition source files and returns every step pattern found as a compiledExpression. Equivalent toscan(File, Consumer)with a callback that does nothing.- Parameters:
glueCodeDir- directory containing the glue code source files- Returns:
- step definition patterns found across all source files; patterns that cannot be compiled are skipped and logged as a warning
-
scan
public List<io.cucumber.cucumberexpressions.Expression> scan(File glueCodeDir, Consumer<File> onFileScanned) Same asscan(File), additionally invokingonFileScannedonce for every source file it processes - whether or not that file contains any step definitions - so a caller can drive a progress indicator during what would otherwise be a single opaque, potentially long-running call across a whole directory tree.- Parameters:
glueCodeDir- directory containing the glue code source filesonFileScanned- invoked once per source file found underglueCodeDir; nevernull- Returns:
- step definition patterns found across all source files; patterns that cannot be compiled are skipped and logged as a warning
-