Skip to main content

Passing scenario tags at runtime when building with Jenkins

When running automated tests, you might want to classify different features and scenarios into different tags for better management.

This tutorial guides you through how to set your scenario tags to be executed at runtime when Jenkins Build triggers your tests.

Requirements

Create Global Variables

You can change global variable values in a test suite during runtime without affecting other test suites. Therefore, using a global variable as a parameter in the keyword runFeatureFolderWithTags can save you time when you have many tags to manage.

  1. Go to Tests Explorer > Profiles to open your desired profiles. Click Add to create a global variable whose values are tags. See Global Variables.
    add global variable

  2. Write a test case with the following keyword:
    runFeatureFolderWithTags(folderRelativePath, tags)
    • folderRelativePath: the folder relative path that starts from the current project location.
    • tags: the global variable defined in step 1.
    Example:
    CucumberKW.runFeatureFolderWithTags('Include/features/BDD Cucumber Tests', GlobalVariable.username)
    Note:
  3. Add this test case to a test suite and execute it from Jenkins.
With the global variable created, you can choose which feature files folder to run with your desired tags values.

Update Global Variables during runtime

To change the global variable by your desired scenario tags during runtime, use the following command syntax -g_XXX, for example, -g_userName="admin".

Read more about running Cucumber feature files at BDD Testing Framework (Cucumber integration).