Detect unused Cucumber step definitions in CI#2349
Detect unused Cucumber step definitions in CI#2349delthas wants to merge 23 commits intodevelopment/2.14from
Conversation
Issue: ZENKO-5203
…he DLQ was ~250 in the tests, stopping sorbetclt from restoring objects Issue: ZENKO-5203
…rs instead of sleep Issue: ZENKO-5203
…prove debugging 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
dedf6c3 to
4a27e41
Compare
maeldonn
left a comment
There was a problem hiding this comment.
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.
0c6fedd to
879ebee
Compare
|
must be rebased, this is not up-to-date with improvement/ZENKO-5203 |
Yes, waiting for that PR to be merged/stabilized |
45cc2d4 to
4925585
Compare
4925585 to
b9c29e8
Compare
Hello delthas,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Branches have divergedThis pull request's source branch To avoid any integration risks, please re-synchronize them using one of the
Note: If you choose to rebase, you may have to ask me to rebuild |
Summary
cucumber-js --dry-run --format usageto detect unused step definitions, and fails thelint-and-build-ctstjob if any are foundHow it works
cucumber-js --dry-runloads all step definitions and cross-references them against every feature file without actually executing any steps. The--format usageoutput lists each step definition alongside its usage count, marking unreferenced ones asUNUSED. The newcheck-unused-steps.shscript greps forUNUSEDin this output and exits non-zero if any are found.Why this branch
This approach requires
cucumber-js --dry-runto load all step definition files. On the main Zenko branches, this fails becausenode-rdkafka(a native C++ addon) is imported transitively by some step files, and it requires system libraries (librdkafka) that aren't available in a plainyarn installenvironment. On this branch (improvement/ZENKO-5203),node-rdkafkahas 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
AfterAllto 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.