Skip to content
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

Add error message/stacktrace to context? #190

Open
jensakejohansson opened this issue May 4, 2022 · 2 comments
Open

Add error message/stacktrace to context? #190

jensakejohansson opened this issue May 4, 2022 · 2 comments

Comments

@jensakejohansson
Copy link

Hi!

I'm able to check if a test is failing in the AfterScenario-hook by the CurrentScenario.IsFailing property. Is it possible to also expose the stacktrace/error message/exception in the context object? The stacktrace is logged by Gauge to file/stdout, but I'd like to be able to fetch it at "teardown" to have more freedom & control since the logging basically happens after I've "lost control" of the execution.

Typically I want to be able to easily send the error/stacktrace-message together with screenshot, scenarioname etc to 3rd-party tools during a test run. We also want to be able to write it to our "own" logfiles. I have no deeper understanding of the Gauge-impl and when the different properties actually receives their values, but after a brief look at the gauge-dotnet source it seems like it could be added as information to hook-context easily? It's just not included at the moment. In my opionen the context should be populated with as much runtime information as possible :)

@sriv
Copy link
Member

sriv commented May 5, 2022

Hi, thanks for the feedback. I agree that the context could be enriched further.

but after a brief look at the gauge-dotnet source it seems like it could be added as information to hook-context easily?

This is not a change in gauge-dotnet alone, since the ExecutionContext is also populated by gauge. gauge-dotnet receives the context from gauge.

The lifecycle is roughly BeforeScenario -> Scenario -> AfterScenario. gauge-dotnet does not maintain the state, since gauge is the one orchestrating this. So, when a scenario fails, the stacktrace needs to be sent back to gauge, which then sends it over to the hooks.

This is not a complicated change, but will require changing both gauge and gauge-dotnet as well as the contract (proto files).

@jensakejohansson
Copy link
Author

jensakejohansson commented May 5, 2022

I see. Would it be possible to ask you to create an appropriate change request on Gauge - you know what to technically ask for - so that you (or some other maintainer of the C#-parts) later can added it to C#? I would be very greatful!

It thought of trying to do a hack and add it myself, but since it seems like changes are needed in Gauge (which is written in Go of which I have no experience), Gauge-DotNet, Gauge-CSharp-Lib (I suppose), so it will probably take me a long time to understand how all this comes together and I'd have to maintain my own code/fork of all this which also is not very appealing...

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

No branches or pull requests

2 participants