Skip to content

New Feature: sub steps #1232

@fider

Description

@fider

Feature description:
Possibility to define substeps, eg:

How it is currently:

// stepDefinition.ts
Then(/"(.*?)" register step 1/, ... );
Then(/"(.*?)" register step 2/, ... );
Then(/"(.*?)" register step 3/, ... );
// If I would like to group them I have to create new step and copy/paste implementation.
// A.feature
Then "device_1" register step 1
Then "device_1" register step 2
Then "device_1" register step 3
// B.feature
Then "device_2" register step 1
Then "device_2" register step 2
Then "device_2" register step 3

How it may looks like:

// stepDefinition.ts
const registerStep1 = Then(/"(.*?)" register step 1/, ... );
const registerStep2 = Then(/"(.*?)" register step 1/, ... );
const registerStep3 = Then(/"(.*?)" register step 1/, ... );
Then(/"(.*?)" complete register/, async (deviceName) => {
  return [registerStep1(deviceName) , registerStep2(deviceName) , registerStep3(deviceName) ]
});
// A.feature
Then "device_1" complete register
// B.feature
Then "device_2" complete register

We can also resue substeps in feature files

// C.feature
Then "device_3" register step 3
// ...
Then "device_3" register step 1

Example html report:
Each step that contains substeps can contain folding/unfolding button (just like featrue and scenario).
image

Why this feature is important:

  • Wrapping cucumber steps into other steps allows me to keep granulation in test steps, reuse code and save a lot of time (eg. let's assume that I just added new steps to "complete register" sequence - I have to update it only in one place instead of 2 or even 50).
  • Without this functionality writing code using cucumber is like programming in language that do not allows you to nest functions calls.
  • I am aware of fact that I can wrap code of "step 1", "2" and "3" into "register complete" but then I will not be able to use each step as standalone fragment of code. Putting whole code into single step limits functionality and make reports less clear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions