Skip to content

Detect unused Cucumber step definitions in CI#2349

Open
delthas wants to merge 22 commits intoimprovement/ZENKO-5203from
improvement/ZENKO-5215/detect-unused-cucumber-steps
Open

Detect unused Cucumber step definitions in CI#2349
delthas wants to merge 22 commits intoimprovement/ZENKO-5203from
improvement/ZENKO-5215/detect-unused-cucumber-steps

Conversation

@delthas
Copy link
Contributor

@delthas delthas commented Mar 12, 2026

Summary

  • Add a CI check that runs cucumber-js --dry-run --format usage to detect unused step definitions, and fails the lint-and-build-ctst job if any are found
  • Remove 4 unused step definitions flagged by this check

How it works

cucumber-js --dry-run loads all step definitions and cross-references them against every feature file without actually executing any steps. The --format usage output lists each step definition alongside its usage count, marking unreferenced ones as UNUSED. The new check-unused-steps.sh script greps for UNUSED in this output and exits non-zero if any are found.

Why this branch

This approach requires cucumber-js --dry-run to load all step definition files. On the main Zenko branches, this fails because node-rdkafka (a native C++ addon) is imported transitively by some step files, and it requires system libraries (librdkafka) that aren't available in a plain yarn install environment. On this branch (improvement/ZENKO-5203), node-rdkafka has been replaced with @platformatic/kafka (a pure JS implementation), so the dry-run loads cleanly without native dependencies.

Alternative approach

An alternative would be to detect unused steps at test runtime rather than as a static CI check — for example by hooking into Cucumber's AfterAll to inspect which step definitions were matched. However, this would only catch unused steps when the full test suite runs, not at lint time, and would be harder to enforce as a gate. The dry-run approach is simpler and catches issues earlier in the pipeline.

SylvainSenechal and others added 21 commits March 11, 2026 15:50
…he DLQ was ~250 in the tests, stopping sorbetclt from restoring objects

Issue: ZENKO-5203
Add a check-unused-steps.sh script that runs cucumber-js in dry-run
mode with usage reporting to detect unused step definitions. Wire it
as an npm script and add it to the lint-and-build-ctst CI job.

Issue: ZENKO-5215
Delete 4 step definitions flagged as UNUSED by the dry-run check:
- Given('an account', ...) in common/common.ts
- Given('{int} mpu objects ...') in common/common.ts
- Then('i can get the {string} location details', ...) in azureArchive.ts
- Given('a DR failing to be installed', ...) in pra.ts

Issue: ZENKO-5215
Remove the check-unused-steps.sh script and inline the command
directly into the npm script. Drop --parallel 1 to use the config
default parallelism.

Issue: ZENKO-5215
@SylvainSenechal SylvainSenechal force-pushed the improvement/ZENKO-5203 branch from dedf6c3 to 4a27e41 Compare March 13, 2026 10:15
Copy link
Contributor

@maeldonn maeldonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you squash or fixup these changes into the relevant commits? Keeping the history clean makes it much easier to follow the logic during future audits.

@SylvainSenechal SylvainSenechal force-pushed the improvement/ZENKO-5203 branch from 4a27e41 to 0c6fedd Compare March 13, 2026 13:24
@SylvainSenechal SylvainSenechal force-pushed the improvement/ZENKO-5203 branch from 0c6fedd to 879ebee Compare March 13, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants