Skip to main content

[Cucumber] Run Feature File with Tags

Description

Katalon Studio supports executing a single feature file with the runFeatureFileWithTags function, using the following tag expressions:

ExpressionDescription
@tag1 and @tag2Features or scenarios tagged with both @tag1 and @tag2.
@tag1 or @tag2Features 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

ParameterParameter TypeRequiredDescription
relativeFilePathStringYesThe relative path to the feature file that starts from the current project location.
tagsString, String[], or String... (Varargs)YesThe tags of the features or scenarios that you want to execute.
flowControl (only valid when tags are of String[] type)FailureHandlingOptionalControls the execution flow if the step fails. Specify failure handling schema to determine whether the execution should be allowed to continue or stop.

Returns

An instance of CucumberRunnerResult that includes the status of the keyword and report folder location.

Examples

Example #1: tags of String type

CucumberKW.runFeatureFileWithTags("Include/features/New Feature File.feature", "@tag1 and @tag2")

Example #2: tags of String[] type

String[] 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

ParameterParameter TypeRequiredDescription
relativeFilePathStringYesThe relative path to the feature file that starts from the current project location.
tagsString or String[]YesThe tags of the features or scenarios that you want to execute.
flowControl (only valid when tags are of String[] type)FailureHandlingOptionalControls the execution flow if the step fails. Specify failure handling schema to determine whether the execution should be allowed to continue or stop.

Returns

An instance of CucumberRunnerResult that includes the status of the keyword and report folder location.

Example

Example #1: tags of String type

CucumberKW.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[] type

String[] 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)
Was this page helpful?