Skip to content

feat: add support for skipping scenarios via SkipScenarioException #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

serhatozdursun
Copy link
Contributor

@serhatozdursun serhatozdursun commented May 12, 2025

Overview

This PR addresses issue #691 by introducing native support for skipping scenarios

🔧 Changes Made

  • ✅ Introduced SkipScenarioException, which can be thrown to trigger a skip.
  • ✅ Updated MethodExecutor to catch SkipScenarioException, mark the step as skipScenario = true, and prevent it from failing.
  • ✅ Included SKIPPED: <reason> messages in the execution result.
  • ✅ Extended StepExecutionStageTest with a new test: testStepMethodExecutionWithSkipScenarioException.

@chadlwilson
Copy link
Contributor

Did you resolve your challenge/confusion noted in the discussion at #691 (comment) ?

@serhatozdursun
Copy link
Contributor Author

@chadlwilson I realized that my initial approach was incorrect, so I rolled back those changes. I’ve now aligned the solution with the approach used in gauge-python/pull/397 which addresses the issue described in gauge-python/issues/390

@serhatozdursun serhatozdursun force-pushed the feat/skip-scenario-support branch from a898386 to 5cee28c Compare May 12, 2025 08:36
@serhatozdursun
Copy link
Contributor Author

@chadlwilson
I added the following lines to ensure the skipScenario flag is preserved across execution stages:

boolean skipped = execResult.getSkipScenario() | previousStageResult.getSkipScenario();
builder.setSkipScenario(skipped);

Without this, a skipped scenario would be incorrectly treated as passed when results are merged.
This change ensures that the skipped state is maintained correctly and reflected in the final execution report.

@chadlwilson
Copy link
Contributor

Cool - seems to make sense. I am not familiar with the merge logic but when you've addressed the checkstyle errors and signed your commits I'll take a deeper look :-) https://github.com/getgauge/gauge-java/pull/924/checks?check_run_id=42041532879

@chadlwilson chadlwilson added the ReleaseCandidate If a PR is tagged with this label, after merging it will be released label May 12, 2025
@gaugebot
Copy link

gaugebot bot commented May 12, 2025

@serhatozdursun Thank you for contributing to gauge-java. Your pull request has been labeled as a release candidate 🎉🎉.

Merging this PR will trigger a release.

Please bump up the version as part of this PR.

Instructions to bump the version can found at CONTRIBUTING.md

If the CONTRIBUTING.md file does not exist or does not include instructions about bumping up the version, please looks previous commits in git history to see what changes need to be done.

@serhatozdursun serhatozdursun force-pushed the feat/skip-scenario-support branch 2 times, most recently from 41f7ef4 to d0bb60a Compare May 12, 2025 11:06
mehmetozdursun and others added 4 commits May 12, 2025 14:15
- Introduced `SkipScenarioException` in the Gauge API to allow users to skip scenarios programmatically.
- Updated `MethodExecutor` to catch `SkipScenarioException` and return a `ProtoExecutionResult` with `skipScenario=true`, an appropriate message, and no failure flag.
- Added unit test `testStepMethodExecutionWithSkipScenarioException` in `StepExecutionStageTest.java` to verify the behavior.

This implements the feature request from issue getgauge#691 by allowing steps to skip execution cleanly using `Gauge.skip("reason")`.

Signed-off-by: mehmetozdursun <[email protected]>
Signed-off-by: serhatozdursun <[email protected]>
fix the format issue which cause the fail

Signed-off-by: serhatozdursun <[email protected]>
Signed-off-by: serhatozdursun <[email protected]>
@serhatozdursun serhatozdursun force-pushed the feat/skip-scenario-support branch from a9f47e8 to 5f028fe Compare May 12, 2025 11:15
@chadlwilson chadlwilson self-assigned this May 12, 2025
@chadlwilson
Copy link
Contributor

Thx - the stage merging is still a bit confusing to me, but seems to me it might have the problem you mention if the skip scenario exception is thrown during a hook rather than during the step itself, or thrown during the step and for a method which has an "after" hook that applies. But I'm also not super familiar with the hooks.

Anyway, I've added a test for that exec result merging, tidied up a bit and will release this. I also changed the message to emit directly what people put in their exception message to return full control to the user rather than prefixing with SKIPPED: (similar to the other language plugins).

@chadlwilson chadlwilson merged commit 88790fc into getgauge:master May 13, 2025
41 of 42 checks passed
@serhatozdursun serhatozdursun deleted the feat/skip-scenario-support branch May 13, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ReleaseCandidate If a PR is tagged with this label, after merging it will be released
Development

Successfully merging this pull request may close these issues.

Support programmatically skipped scenarios (e.g if a scenario has a dependency failure)
3 participants