Navigation
A spec file and the Java code that runs it stay connected. The plugin makes a link from each element in the spec file to the Java code that belongs to that element. Almost every element has such a link: the feature, the rules, the scenarios, the background, the steps, the values in a step, the tags, and the cells of an Examples table.
The links also operate in the opposite direction, from the Java code back to the spec file. Thus you can move between the spec file and the code with one gesture, and you do not have to search for the related part.
From the spec file to the code
Press Cmd+Click or Ctrl+Click on almost all elements in a spec file. The IDE opens the related
Java code.
| In the spec file | The IDE opens |
|---|---|
Feature: keyword, title or description(aliases: Ability:, Business Need:) | the generated test class |
Rule: | its @Nested class |
Scenario:(alias: Example:) | the @Test method |
Scenario Outline:(alias: Scenario Template:) | the @ParameterizedTest method |
Background: | the generated @BeforeEach method, for the feature or for the rule |
| A step, or its keyword | the step method implementation, or its declaration if it is not implemented yet |
| A value in quotation marks in a step | the related parameter of the step method |
| A doc string or a data table | the parameter that it became |
| A tag, at each level | the related @Tag annotation |
An Examples header cell | the @CsvSource annotation |
An Examples data cell | the row in the @CsvSource annotation |
<A spec file with the pointer on a step, the step text underlined as a link, and the editor tab of the class that holds the step method open behind it.>
Two destinations for navigating from a step
Cmd+Click or Ctrl+Click on a step opens the implemented step method.
Cmd+Shift+Click or Ctrl+Shift+Click opens the call of the step method. This is the line in the
generated scenario test method that calls the step. For a background step, this line is in the
@BeforeEach method. Thus you can see where the generated code calls the step.
<The same step in the spec file beside the generated scenario method, with the call of that step highlighted in the sequence of the other calls.>
From the code back to the spec file
The same gestures operate in the opposite direction. From the generated test class you go to the
Feature: line. From a @Nested class you go to its Rule:. From a @Test method you go to its
Scenario:. From a @BeforeEach method you go to Background:. From a call of a step you go to
the related step, with Cmd+Shift+Click or Ctrl+Shift+Click.
The plugin finds the correct element. Two scenarios with the same title go to the correct scenario. A step that occurs two times in a scenario goes to the occurrence that you clicked.
<A generated
@Testmethod in the Java editor with the pointer on its@DisplayNamevalue, and the scenario that it came from open in the other editor pane.>