godog
godog copied to clipboard
Ability to define WHERE step definitions / features are located
🤔 What's the problem you're trying to solve?
Attempt to centralize test code in one area, instead of all of the test code scattered across the entire project. I understand it's not necessarily idiomatic Go code, but it's more in line with how BDD test code is written in other languages.
I'm frustrated when I'm trying to run a regression on my entire project, and I have to find individual files instead of being able to run and find all of my test code within one folder
✨ What's your proposed solution?
Some way to specify where the source of the step definitions and feature files should be.
This could be either a cli argument, or some sort of setting file, or even a field that can be set in the context struct.
⛏ Have you considered any alternatives or workarounds?
When it comes to location of the files it seems diifficult to see any workaround that aren't being able to move the files.
📚 Any additional context?
For example, within the Java Cucumber support, you can define specifically where the features are located. The feature files themselves are able to map to step definitions anywhere in the project.
This text was originally generated from a template, then edited by hand. You can modify the template here.
Hello @sumusjack, you can define where features/steps definitions are located. Take this example as reference https://github.com/cucumber/godog/blob/main/_examples/assert-godogs/godogs_test.go. In contexts initialization you can define the function where all scenario contexts are defined. And in options you can set the Paths property with your features' paths.
By doing so you can centralize your tests in one place and when you run go test
in your project the BDD tests will run as well
Hello @gnoe. Can I define where the tests files are located?
E.g.: features |__ godog.feature services |__ godog_test.go
Yes. As @gnoe has said, you can specify the path of your feature file godog.feature
within your test godog_test.go
using the Paths
field.
This isn't working. What am i doing wrong?
add the file names to the paths list.
...
Paths: []string{"../features/users.feature"}
...
add the file names to the paths list.
... Paths: []string{"../features/users.feature"} ...
didn't work
What is the command you executed?
Just godog run
run go test
inside the services
directory.
worked! thanks @roskee
Thank you @roskee for replying and sorry @gabrielcartellivia for didn’t reply on time. I'm glad that it worked!
@gabrielcartellivia can we close this issue?