Passing feature file and 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 will guide you through how to set your scenario tags to be executed at runtime when Jenkins Build triggers your tests.

Requirement:

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 your time when you have many tags to manage.

  1. In the Tests Explorer, go to Profiles to open your desired Profiles. Click Add to create a Global Variable which 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)
    

    Notes:

    To learn more about this keyword, see [Cucumber] Run Feature Folder with Tags.

  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).

Feedback