Comments (4)
Hi, thanks. That is something what needs to be improved. Currently caught panics does not print stack trace, which needs to be changed. probably an error should have a different type similar to https://github.com/pkg/errors so it could print stack trace in verbose mode on %+v
Currently what I suggest you to do, is catch panic in your step in order to debug the reason. Later when I have some more time, I will revisit this. The issue is important but not critical to behavior. Thanks for reminding.
from godog.
Thx @l3pp4rd , how do I print a stack trace if all print statements are swallowed?
from godog.
to replicate it, lets simply create a small feature:
Feature: panic
Scenario: panics
Then fail with panic
Now implement the panic step in _test.go file.
package main
import (
"fmt"
"github.com/DATA-DOG/godog"
)
func myStepCallsFunc() {
arr := make([]int, 0)
fmt.Println(arr[6])
}
func failWithPanic() error {
myStepCallsFunc()
return nil
}
func FeatureContext(s *godog.Suite) {
s.Step(`^fail with panic$`, failWithPanic)
}
Run it:
Then lets print stack trace of panic instead.
package main
import (
"fmt"
"runtime/debug"
"github.com/DATA-DOG/godog"
)
func myStepCallsFunc() {
arr := make([]int, 0)
fmt.Println(arr[6])
}
func failWithPanic() (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("runtime error: %s", r)
debug.PrintStack()
}
}()
myStepCallsFunc()
return
}
func FeatureContext(s *godog.Suite) {
s.Step(`^fail with panic$`, failWithPanic)
}
And you see the output now:
from godog.
The simple answer is to use "log" which still outputs. Apologies for the noise.
from godog.
Related Issues (20)
- Support for Go 1.20
- runAfterScenarioHooks invoke twice when step failed that is not the last step HOT 4
- Enhancement to allow to skip a test from the code HOT 8
- Background Outline HOT 2
- Setting option `Concurrency = 2` fails when running the Example HOT 1
- click on run tests but tests are not running HOT 1
- Please update the concurrency paragraph in the docs to clarify if scenario outlines run in parallel or only the scenarios HOT 1
- Is this feature file in godog/_examples/godogs running sequencially ? HOT 2
- Why Getting total scenarios as 6 while I am having total 5 scenarios HOT 3
- Skipping a test by returning `godog.ErrSkip` does not work? HOT 4
- print error stack when panic
- step function support return a nil Context with error HOT 1
- Conflict between global flags set by godog.BindCommandLineFlags and spf13/cobra HOT 1
- HELP: I want to know the index of a scenario in a scenario outline in the before scenario hook.
- Can't navigate to step definition from Gherkin step
- Unexpected step line values in cucumber report generated by Godog for scenario outlines
- ReadMe add step `go get ...` see provided patch to fix it
- Tag Filtering Expressions HOT 2
- Calculated step duration is wrong HOT 3
- Support for attachments / embeddings as per Cucumber and Behave HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godog.