Package io.karatelabs.core
Class StepUtils
java.lang.Object
io.karatelabs.core.StepUtils
Static utility methods for step execution.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordParsed result of a feature path with optional tag selector. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectDeep copy a value (Map, List, or primitive).static intfindAssignmentOperator(String text) Find the first '=' that's an assignment operator (not ==, !static intfindCallArgSeparator(String text) Find the separator between call target and arguments in a call expression.static ObjectgetOrCreatePath(Map<String, Object> target, String path) Navigate to or create a nested path in a map structure.static booleanCheck if string contains JS expression punctuation like . ( [ ] ' "static booleanisLiteralFeatureRead(String text) Check if text is a literal feature file read like read('file.feature').static booleanisValidVariableName(String name) Check if a string is a valid Karate variable name.static StepUtils.ParsedFeaturePathparseFeaturePath(String rawPath) Parse a feature path into path and tag selector components.static voidremoveAtPath(Map<String, Object> map, String path) Remove a value at a nested path in a map.static voidsetValueAtPath(Object target, String path, Object value) Set a value at a nested path, handling both dot notation and array brackets.static StringConvert a value to its string representation
-
Method Details
-
parseFeaturePath
Parse a feature path into path and tag selector components. Supports: - file.feature@tag - call specific scenario by tag - @tag - call scenario in same file by tag - file.feature - normal call without tag- Parameters:
rawPath- the raw path string (may contain @tag suffix)- Returns:
- ParsedFeaturePath with separated path and tag components
-
isValidVariableName
Check if a string is a valid Karate variable name. Must start with letter or underscore, followed by letters, digits, or underscores. -
findCallArgSeparator
Find the separator between call target and arguments in a call expression. Handles quoted strings in read() calls, e.g., read('foo bar.js') arg- Returns:
- index of separator space, or -1 if not found
-
isLiteralFeatureRead
Check if text is a literal feature file read like read('file.feature'). -
deepCopy
Deep copy a value (Map, List, or primitive). -
getOrCreatePath
Navigate to or create a nested path in a map structure. Creates intermediate maps as needed. -
setValueAtPath
Set a value at a nested path, handling both dot notation and array brackets. -
removeAtPath
Remove a value at a nested path in a map. -
findAssignmentOperator
Find the first '=' that's an assignment operator (not ==, !=, invalid input: '<'=, >=).- Parameters:
text- the text to search- Returns:
- index of '=' or -1 if not found
-
hasPunctuation
Check if string contains JS expression punctuation like . ( [ ] ' "- Parameters:
s- the string to check- Returns:
- true if contains punctuation
-
stringify
Convert a value to its string representation. - null -> "null" - String -> as-is - Map/List -> JSON - Node -> XML - Other -> toString()- Parameters:
value- the value to stringify- Returns:
- string representation
-