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

The stacktrace available in the Execution Context should be complete #146

Open
sswaroopgupta opened this issue Apr 23, 2018 · 4 comments
Open

Comments

@sswaroopgupta
Copy link
Contributor

sswaroopgupta commented Apr 23, 2018

Expected behavior
The complete stacktrace is available

Actual behavior
The stacktrace available is truncated.

Steps to replicate

  • Create a gauge-java project
  • Throw an exception in a step

The stacktrace in Execution context is not complete

Version

Gauge version: 0.9.8.nightly-2018-04-19
Commit Hash: 58298e2

Plugins
-------
java (0.6.7.nightly-2018-04-16)

Related to #125

@ajoecker
Copy link
Contributor

can you post a truncated stacktrace ?

I get

# Specification Heading
  ## Vowel counts in single word         P F
        Failed Step: The word "gauge" has "3" vowels.
        Specification: specs\example.spec:16
        Error Message: java.lang.NullPointerException: This is wrong
        Stacktrace:
        StepImplementation.verifyVowelsCountInWord(StepImplementation.java:24)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.base/java.lang.reflect.Method.invoke(Method.java:564)
        com.thoughtworks.gauge.execution.MethodExecutor.execute(MethodExecutor.java:38)
        com.thoughtworks.gauge.execution.StepExecutionStage.executeStepMethod(StepExecutionStage.java:74)
        com.thoughtworks.gauge.execution.StepExecutionStage.executeStep(StepExecutionStage.java:67)
        com.thoughtworks.gauge.execution.StepExecutionStage.execute(StepExecutionStage.java:49)
        com.thoughtworks.gauge.execution.AbstractExecutionStage.executeNext(AbstractExecutionStage.java:24)
        com.thoughtworks.gauge.execution.HookExecutionStage.execute(HookExecutionStage.java:43)
        com.thoughtworks.gauge.execution.ExecutionPipeline.start(ExecutionPipeline.java:29)
        com.thoughtworks.gauge.processor.ExecuteStepProcessor.process(ExecuteStepProcessor.java:45)
        com.thoughtworks.gauge.connection.MessageDispatcher.dispatchMessages(MessageDispatcher.java:92)
        com.thoughtworks.gauge.GaugeRuntime.dispatchMessages(GaugeRuntime.java:96)
        com.thoughtworks.gauge.GaugeRuntime.lambda$connectSynchronously$1(GaugeRuntime.java:79)
        java.base/java.lang.Thread.run(Thread.java:844)

  ## Vowel counts in multiple word       P P

Successfully generated html-report to => C:\Users\ajoecker\dev\gauge-init-java\reports\html-report\index.html
Specifications: 1 executed      0 passed        1 failed        0 skipped
Scenarios:      2 executed      1 passed        1 failed        0 skipped

Total time taken: 566ms

which looks fine ?!

Version

$ gauge -v
Gauge version: 0.9.7
Commit Hash: bc9784c

Plugins
-------
html-report (4.0.3)
java (0.6.7.nightly-2018-04-27)
screenshot (0.0.1)
spectacle (0.1.2)

@nehashri
Copy link
Contributor

nehashri commented May 2, 2018

We decided to leave the stacktrace as is (that is in its truncated form). The reason being, the user in most of the cases should be worrying about the internals of Gauge and will not need Gauge's stacktrace.
If someone sees a need for this, please feel free to comment and tell us why you would need this kind of stacktrace.

@glalejos
Copy link

The information that I'm missing are nested exceptions. It's OK not to show that information in the regular Gauge output, but there should be an easy way to get as much exception information as possible when things start to get complicated.
My suggestion is to include a reference to the top level Throwable in the StepDetails object pased via the ExecutionContext of an @AfterStep method. This way the tester will be able to format the exception at his/her convenience.
Ref. #189.

@sixcorners
Copy link
Contributor

sixcorners commented Feb 23, 2022

What's missing is not Gauge's stacktrace but the caused by of the exception that does get logged.
The output I'm looking at is equivalent to this:

        Failed Step: The word "gauge" has "3" vowels.
        Specification: specs\example.spec:16
        Error Message: java.lang.ExceptionInInitializerError 
        Stacktrace:
        StepImplementation.verifyVowelsCountInWord(StepImplementation.java:24)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.base/java.lang.reflect.Method.invoke(Method.java:564)
        com.thoughtworks.gauge.execution.MethodExecutor.execute(MethodExecutor.java:38)
        com.thoughtworks.gauge.execution.StepExecutionStage.executeStepMethod(StepExecutionStage.java:74)
        com.thoughtworks.gauge.execution.StepExecutionStage.executeStep(StepExecutionStage.java:67)
        com.thoughtworks.gauge.execution.StepExecutionStage.execute(StepExecutionStage.java:49)
        com.thoughtworks.gauge.execution.AbstractExecutionStage.executeNext(AbstractExecutionStage.java:24)
        com.thoughtworks.gauge.execution.HookExecutionStage.execute(HookExecutionStage.java:43)
        com.thoughtworks.gauge.execution.ExecutionPipeline.start(ExecutionPipeline.java:29)
        com.thoughtworks.gauge.processor.ExecuteStepProcessor.process(ExecuteStepProcessor.java:45)
        com.thoughtworks.gauge.connection.MessageDispatcher.dispatchMessages(MessageDispatcher.java:92)
        com.thoughtworks.gauge.GaugeRuntime.dispatchMessages(GaugeRuntime.java:96)
        com.thoughtworks.gauge.GaugeRuntime.lambda$connectSynchronously$1(GaugeRuntime.java:79)
        java.base/java.lang.Thread.run(Thread.java:844)

What caused the ExceptionInInitializerError? There isn't a way to tell here.

The "caused by" and the suppressed exceptions should be logged too.

zabil added a commit that referenced this issue Apr 14, 2022
* Fix stack trace printing (#146)

This code will print the "Caused By" and any suppressed exceptions.

* bump gauge-java -> 0.89.0

Signed-off-by: sixcorners <[email protected]>

* Update to correct bumped version

Fix build issues by updating to the correct version

Signed-off-by: Zabil Cheriya Maliackal <[email protected]>

Co-authored-by: Srikanth <[email protected]>
Co-authored-by: Zabil Cheriya Maliackal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants