Refactor scenarios

Applies to CucumberStudio Cloud, and to Enterprise ver. 3.3 - 3.5.6.0. Last updated on November 17, 2023

Why refactoring?

Testing at the speed and scale of Agile requires automation and maintainable test design. And one root of the maintenance problems is copy/paste.

That’s the reason why CucumberStudio enables test refactoring. Tests should be reviewed and refactored continuously, just like code. This section describes the main refactoring principles.

Promote

When you have a group of steps you want to reuse across multiple scenarios, extract them into an action word. This refactoring technique makes your steps reusable and easy to maintain. Don’t repeat yourself!

  1. First select the group of steps and select Convert into action word:

    Convert into action word

    Click the image to enlarge it.

  2. If several scenarios already use this group of steps, then select the ones you want to apply the refactoring to:

    Convert into action word modal

    Click the image to enlarge it.

  3. You are done. The action word has been created with the group of steps and the scenarios you have selected now call the new action word directly.

    Convert into action word done

    Click the image to enlarge it.

Inline

Inline is the opposite of promote. It replaces an action word by its steps in every object where this action word is called.

  1. Select your action word and click on Inline:

    Action word inline

    Click the image to enlarge it.

  2. Review all the objects (scenarios and action words) calling the action word to be inlined:

    Action word inline modal

    Click the image to enlarge it.

  3. All the references to this action word have been replaced by the steps of the action word.

    Action word inline done

    Click the image to enlarge it.

Rename

Make sure that action word naming is meaningful because it keeps test readability and do not hesitate to rename an action word: all the references (call) to this action word are updated automatically.

Action word renaming

Click the image to enlarge it.

See Also

Best practices for scenario writing

Highlight search results