Editing Feature Files
Creating a New Feature
In the Explorer view, right-click on the folder in which you want to create the new feature file. Select "New Cycle File" and then "New Feature..." from the context menu.
VS Code will then open an input box at the top of the editor window for the feature file name.
Enter the name you want to give the feature file.
This name will become the file name as well as the Feature
title.
Do not use special characters in this name, and do not append a file extension.
VS Code will automatically append the .feature
extension to the file name.
Viewing Step Assistant
Every CycleScript step has helpful information about it through Step Assistant. Hover over the step to trigger a modal with the Step Assistant information.
Automatically Completing Steps
As you type steps, the editor will provide suggestions for how to complete the step's text. Select the desired option from the suggestions to use it in the feature file.
Identifying Syntax Errors
The editor marks any syntax errors for incorrect CycleScript syntax or step texts with red underlines.
Toggling Comments
Lines for CycleScript comment start with the #
character.
It is common to temporarily "comment out" steps or even whole scenarios while editing and debugging feature files.
Rather than type the #
character for every single line,
you can highlight multiple lines and then type Ctrl+/
to add or remove the #
character from them at once.
Using CycleScript Snippets
Snippets are templatized blocks of code that you can insert into a file. They help you use proper syntax and structure. The Cycle Testing extension provides the following snippets:
To use a snippet, type the name of the snippet on a new line. Snippet options should then pop up in a modal. Select the desired snippet.
The editor will insert the snippet's code directly into the feature file. Replace the highlighted sections with appropriate CycleScript code and steps.
Please note that snippet names are case-sensitive.
For example, you must select if
and not If
for the If statement's snippet.
Navigating to Scenarios
In CycleScript, a scenario can call another scenario by using the I execute scenario "..."
step,
where "..."
is the name of the scenario to call.
To see the called scenario's code, hover over the step, and press and hold the Ctrl
key.
The scenario name will turn into a blue hyperlink.
Click the name while holding the Ctrl
key.
VS Code will open the feature file containing the called scenario and navigate to the scenario's definition within it.