Skip to main content

[Cucumber] Run Feature Folder with Tags

Katalon Studio supports executing feature files in a folder with the runFeatureFolderWithTags 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.

Description​

Query the feature files in the specified folder, and execute the features or scenarios associated with all or any of the input tags.

Keyword name: runFeatureFolderWithTags

Keyword syntax: runFeatureFolderWithTags(folderRelativePath, tags, cucumberRunOptions, flowControl)

Parameters​

ParameterParameter TypeRequiredDescription
folderRelativePathStringYesThe folder relative path starts from the current project location. To rerun failed scenarios, provide the path to your rerun file prefixed with @ (e.g., @rerun.txt).
tagsString, String[], or String... (Varargs)YesThe tags of the features or scenarios that you want to execute.
cucumberRunOptionsMapNoA map of options to configure the Cucumber execution. Use failedTestFilePath to specify a file path where failed scenarios will be saved.
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: Using tags of String type

// With AND expression
CucumberKW.runFeatureFolderWithTags("Include/features/BDD Cucumber Tests/", "@tag1 and @tag2")

// With OR expression
```jsx
CucumberKW.runFeatureFolderWithTags("Include/features/BDD Cucumber Tests/", "@tag1 or @tag2")

Example 2: Using tag arrays (String[])

// With AND expression
String[] logTags = ["@tag1 and @tag2"] as String[]
CucumberKW.runFeatureFolderWithTags("Include/features/BDD Cucumber Tests/", logTags, FailureHandling.STOP_ON_FAILURE)

//With OR expression
String[] logTags2 = ["@tag1 or @tag2"] as String[]
CucumberKW.runFeatureFolderWithTags("Include/features/BDD Cucumber Tests/", logTags2, FailureHandling.STOP_ON_FAILURE)

Example 3: Using Varargs (String...)

CucumberKW.runFeatureFolderWithTags("Include/features/BDD Cucumber Tests/", "@tag1 and @tag2")

Example 4: Capture and rerun failed scenarios

import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.model.FailureHandling

// Run folder with tags
CucumberKW.runFeatureFolderWithTags('Include/features', ["@smoke and not @wip"] as String[],
[failedTestFilePath: 'failed-smoke-suite.txt'], FailureHandling.CONTINUE_ON_FAILURE)
// Rerun failed scenarios from folder execution
CucumberKW.runFeatureFolder('@failed-all-features.txt',
[failedTestFilePath: 'failed-all-features-retry.txt'])
Was this page helpful?