go-bdd / gobdd

BDD framework
https://go-bdd.github.io/gobdd/
MIT License
115 stars 19 forks source link

Add `Name() string` to `StepTest` interface #117

Closed jirikuncar closed 3 years ago

jirikuncar commented 4 years ago

Is your feature request related to a problem? Please describe. I would like to be able to use the step name for logging and tracing.

Describe the solution you'd like Add Name() string to StepTest.

Describe alternatives you've considered t.(*testing.T))

Additional context TBD

github-actions[bot] commented 4 years ago

Thanks for creating your first issue! We are thankful for your help

sagikazarmark commented 4 years ago

If you use t.Log functions, it should already group the output under the right test.

What's your use case?

jirikuncar commented 4 years ago

@sagikazarmark tracing and VCR recording. The work around with t.(*testing.T)) is working but it's not really nice.

bkielbasa commented 4 years ago

exposing the t to the context comes back. Again. But, it will break the backwards compatibility because we'll have to pass the t to the NewContext() function https://github.com/go-bdd/gobdd/blob/master/context.go#L13.

What I can suggest is to add a new function to the context and call it ctx.T() or ctx.Logger() that will return an interface with logging capabilities.

Are there any other use cases where the testing.T will be useful?

jirikuncar commented 4 years ago

@bkielbasa maybe t.Cleanup() in Go 1.14?

bkielbasa commented 3 years ago

you have Before and AfterSuite functions. Do you need more than that?

What's more, doesn't the standard output fit your need? Could you provide an example?

This task is quite old now. I think I'll close it for now but don't hesitate to reopen it if needed :)