[Cucumber] Run Feature File with Tags
Description
Katalon Studio supports executing a single feature file with the runFeatureFileWithTags
function, using the following tag expressions:
Expression | Description |
---|---|
@tag1 and @tag2 | Features or scenarios tagged with both @tag1 and @tag2 . |
@tag1 or @tag2 | Features or scenarios tagged with either @tag1 or @tag2 . |
To learn more about tag expressions, refer to this Cucumber document: Cucumber tag expression.
Using the AND tag expression
- Description: execute the features or scenarios associated with all the input tags.
- Keyword name: runFeatureFileWithTags.
- Keyword syntax: runFeatureFileWithTags(relativeFilePath, tags, flowControl).
- Parameters:
- Name: relativeFilePath
- Description: the relative path to the feature file that starts from the current project location.
- Parameter Type:
String
. - Mandatory: required.
- Name: tags
- Description: the tags of the features or scenarios that you want to execute.
- Parameter Type:
String
,String[]
, orString...
(Varargs). - Mandatory: required.
- Name: flowControl (only valid when tags are of
String[]
type) - Description: an that controls the running flow.
instance com.kms.katalon.core.model.FailureHandling
- Parameter Type:
FailureHandling
. - Mandatory: optional.
- Returns: an instance of
CucumberRunnerResult
that includes the status of keyword and report folder location. -
Example:
Example #1: tags of
String
typeCucumberKW.runFeatureFileWithTags("Include/features/New Feature File.feature", "@tag1 and @tag2")
Example #2: tags of
String[]
typeString[] logTags = ["@tag1", "@tag2"] as String[]
CucumberKW.runFeatureFileWithTags("Include/features/New Feature File.feature", logTags, FailureHandling.STOP_ON_FAILURE)Example #3: tags of
String...
type (Varargs)CucumberKW.runFeatureFileWithTags("Include/features/New Feature File.feature", "@tag1", "@tag2")
Using the OR tag expression
Description: execute the features or scenarios associated with any of the input tags.
- Keyword name: runFeatureFileWithTags
- Keyword syntax: runFeatureFileWithTags(relativeFilePath, tags, flowControl).
- Parameters:
- Name: relativeFilePath
- Description: the relative path to the feature file that starts from the current project location.
- Parameter Type:
String
- Mandatory: required
- Name: tags
- Description: the tags of the features or scenarios that you want to execute.
- Parameter Type:
String
orString[]
. - Mandatory: required
- Name: flowControl (only valid when tags are of
String[]
type) - Description: an instance
com.kms.katalon.core.model.FailureHandling
that controls the running flow. - Parameter Type:
FailureHandling
. - Mandatory: optional.
- Returns: an instance of
CucumberRunnerResult
that includes the status of keyword and report folder location. Example:
Example #1: tags of
String
typeCucumberKW.runFeatureFileWithTags("Include/features/New Feature File.feature", "@tag1 or @tag2")
// Or
CucumberKW.runFeatureFileWithTags("Include/features/New Feature File.feature", "@tag1, @tag2")Example #2: tags of
String[]
typeString[] logTags1 = ["@tag1, @tag2"] as String[]
CucumberKW.runFeatureFileWithTags("Include/features/New Feature File.feature", logTags1, FailureHandling.STOP_ON_FAILURE)
// Or
String[] logTags2 = ["@tag1 or @tag2"] as String[]
CucumberKW.runFeatureFileWithTags("Include/features/New Feature File.feature", logTags2, FailureHandling.STOP_ON_FAILURE)