Example Editing
This section introduces how to use Example Tables (Examples) to achieve data-driven testing in BDD.
What is an Example Table?
During testing, if you need to verify the same set of operation steps using multiple different sets of parameters, you can manage this data through an Example table without having to repeatedly write the same scenario or steps.
An Example table (Examples) is typically used in conjunction with a Scenario Outline as its associated data source.
How it Works
- In a Scenario Outline, use placeholders (e.g.,
<username>,<password>) instead of fixed parameters. - CukeTest iterates through each row of data in the associated Example table and automatically fills the corresponding placeholders with that data.
- Each row of data triggers a scenario instantiation and is executed independently.
Tip
Tip: A scenario outline can be associated with one or more Example tables. If a scenario outline has no Example tables configured, that scenario will be skipped during execution.

Using Multiple Example Tables
In some complex scenarios (e.g., verifying different boundary cases of a refund business), you can categorize test data into multiple Example tables.
Combined with the Tags feature, you can set specific tags for each Example table. This way, during test execution, you can use the tag filtering mechanism to run only specific groups of Example table data.
Usage of Example Tables
CukeTest supports two management methods: Internal Example Tables and Linked External Example Tables.
1. Internal Example Tables
Define and save test data directly within the Feature file.
- Creation: In Visual Mode, right-click the title of a Scenario Outline and select
Add Instance. - Editing: Double-click a cell to enter the editing state. Use the
Tabkey to quickly jump to the next cell and save automatically.
For example, in a login test, you can define multiple test cases such as invalid characters, empty passwords, and normal login through an Example table:
Example cited from CNodeJS Community UI Automation Project.
2. Linked External Example Tables
When the volume of test data is large or needs to be maintained by other business departments, you can use external files as data sources.
Linked Example Tables allow the feature file to directly call externally stored test datasets, keeping the feature content concise.
- Operation: Right-click the scenario outline and select
Add Linked Example Table, or click the link icon
in the Example table toolbar to select the target file.
Note
Note: CukeTest currently only supports linking .csv table files created using standard comma-separated protocols.
Once configured, the external data will be displayed directly in the feature editor:
If we switch the view to Text Mode, the underlying Gherkin code mapping is very simple:
Scenario Outline: User Registration
Given I have navigated to the user registration page
When I enter "<username>" in the username field
When I enter "<password>" in the password field
When I enter "<confirm>" in the confirm password field
When I enter "<email>" in the email field
Then I click the register button
Examples:
#data_source: ..\data.csv
Note
You will notice that for linked Example tables, the core is that special instruction following the Examples header: #data_source: + file path declaration.
Limitations of Linked Tables
- Read-only View: The table view displayed for a linked Example table is only for conveniently observing the external dataset without leaving the software. You cannot directly modify it in this interface. You must open the source file to save changes, then right-click the linked table and click "Refresh" to reload the new data.
- Mind the Platform Slashes: When writing backslashes like
..\data.csvin a relative path, remember that due to differences between operating systems, this path format may only be parsed on Windows. If you are on a cross-platform team, it is recommended to always use the standard forward slash/as a separator for multi-level directories.
Combination of Example Tables and Doc Strings
Example tables can not only provide values for ordinary step parameters but also use <variable_name> for replacement within Doc Strings and Step Tables.
In other words:
<variable>can appear in Step Text- It can also appear in Doc Strings
- It can also appear in Step Tables
When executing a scenario, the framework replaces these placeholders with data from the Examples table.
Example:
Scenario Outline: Using Example data in Doc Strings and Step Tables
Given I use long text
"""
The placeholder in this text will be replaced: <text>
"""
When I use step table data
| id | value |
| 1 | <data> |
Examples:
| text | data |
| Example Text 1 | Dynamic Value |
During execution:
<text>will be replaced withExample Text 1<data>will be replaced withDynamic Value
Keyboard Shortcuts for Example Tables
When an Example table is in edit mode, you can use the following shortcuts for fast editing:
| Shortcut | Action |
|---|---|
Enter or Tab |
Save the current cell and move to the next cell |
Shift + Enter or Shift + Tab |
Save the current cell and move to the previous cell |
These shortcuts help you quickly enter or modify data in the table.