Skip to main content

Finding step usages

Finding usages of a step method lists every step line in the spec files that calls the method, alongside the calls in the Java code. Where a step is used is then visible before the step method changes — for example, before renaming the method or changing its parameters (see Refactoring steps).

In the Find window​

Right-click the step method's name in the Java code and choose Find Usages (Alt+F7). The Find tool window opens at the bottom of the IDE and lists the usages grouped by file: the step lines in the spec files, and the calls in the Java code.

The list contains every occurrence: a step used twice in the same scenario appears twice in the list. The list also contains the background steps, and the steps that start with And, But or *.

Right-click the step method, choose Find Usages, and four usages come back — two of them step lines in spec files, listed beside the generated call sites rather than instead of them.

In a popup with Cmd+Click​

For a quick look, hold Cmd (Ctrl on Windows and Linux) and click the step method's name where the method is declared. The same list of usages opens in a small popup over the code, and the Find tool window stays closed. Clicking an entry in the popup opens that step line in the spec file; pressing Esc closes the popup.

Cmd+Click on the method name shows the same four usages in a popup over the code.

Backed by the Java compiler​

In SpecBinder, a step is not matched to a step method by searching for text. At build time each step in a spec file becomes an ordinary Java method call in the generated test code, and the compiler checks every one of those calls: a step with no matching method is a compile error.

Finding usages builds on the same Java calls. The IDE follows real references, exactly as it does for any other Java method, and the plugin maps each generated call back to the step line it came from. So the list is complete and exact: every step that calls the method is in the list.