Skip to content
New issue

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

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

Already on GitHub? # to your account

Add support to skip scenarios on runtime #390

Closed
sschulz92 opened this issue Sep 26, 2024 · 3 comments · Fixed by #397
Closed

Add support to skip scenarios on runtime #390

sschulz92 opened this issue Sep 26, 2024 · 3 comments · Fixed by #397

Comments

@sschulz92
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I need to skip scenarios on runtime as the system-under-test differs. Therefore I would like to have the Python-runner to support the PR: getgauge/gauge#2502

Describe the solution you'd like
Apply the changes done in C# also for Python.

Describe alternatives you've considered
None

Additional context
C# PR: getgauge/gauge-csharp-lib#42

@chadlwilson
Copy link
Contributor

If you want to have a go at implementing this, I am happy to make it a little easier by updating the protobufs to the latest so the message API is exposed to be consumed within the plugin :-)

@sschulz92
Copy link
Contributor Author

If you want to have a go at implementing this, I am happy to make it a little easier by updating the protobufs to the latest so the message API is exposed to be consumed within the plugin :-)

Currently I am struggeling to understand where I need to throw and catch the "SkipScenarioException" in order to send the Gauge.Message to skip execution.

My assumption:

def execute_method(params, step, response, is_continue_on_failure=_false):
    start = _current_time()
    try:
        params = _get_args(params, step)
        step.impl(*params)
    except Exception as e:
        _add_exception(e, response, is_continue_on_failure(step.impl, e))
    response.executionResult.executionTime = _current_time() - start
    response.executionResult.message.extend(MessagesStore.pending_messages())
    response.executionResult.screenshotFiles.extend(ScreenshotsStore.pending_screenshots())

If I catch the skip exception before the global exception, I would be able to overwrite the flag response.executionResult.skipScenario. Am I on the right track? 😄

@chadlwilson
Copy link
Contributor

I think something like that, yes.

The gauge-dotnet impl (the first impl of this) basically looks at the exception type/name and sets the flag along with the equivalent ofresponse.executionResult.success = true (in contrast to for other types of exceptions.

https://github.com/getgauge/gauge-dotnet/pull/210/files#diff-664ffb133211070e87590f3c0c836d8a2f3b56c9b17c81c24a08479e5d26848dR58-R80

When the exception is raised by the user, the reason is reported with a message.

https://github.com/getgauge/gauge-csharp-lib/pull/42/files#diff-8c944c5931788afb31fb92049426343c0f2f96f846906dbb4b65b485ad811c6cR16

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants