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

Ability to define WHERE step definitions / features are located #506

Open
sumusjack opened this issue Oct 17, 2022 · 12 comments
Open

Ability to define WHERE step definitions / features are located #506

sumusjack opened this issue Oct 17, 2022 · 12 comments

Comments

@sumusjack
Copy link

sumusjack commented Oct 17, 2022

🤔 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.

image

This text was originally generated from a template, then edited by hand. You can modify the template here.

@gnoe
Copy link

gnoe commented Nov 7, 2022

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

@gabrielcartellivia
Copy link

Hello @gnoe. Can I define where the tests files are located?

E.g.:
features
|__ godog.feature
services
|__ godog_test.go

@roskee
Copy link
Member

roskee commented Jan 25, 2023

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.

@gabrielcartellivia
Copy link

gabrielcartellivia commented Jan 25, 2023

image
image

This isn't working. What am i doing wrong?

@roskee
Copy link
Member

roskee commented Jan 25, 2023

add the file names to the paths list.

...
Paths: []string{"../features/users.feature"}
...

@gabrielcartellivia
Copy link

add the file names to the paths list.

...
Paths: []string{"../features/users.feature"}
...

image

didn't work

@roskee
Copy link
Member

roskee commented Jan 25, 2023

What is the command you executed?

@gabrielcartellivia
Copy link

gabrielcartellivia commented Jan 25, 2023

Just godog run

@roskee
Copy link
Member

roskee commented Jan 25, 2023

run go test inside the services directory.

@gabrielcartellivia
Copy link

worked! thanks @roskee

@gnoe
Copy link

gnoe commented Jan 25, 2023

Thank you @roskee for replying and sorry @gabrielcartellivia for didn’t reply on time.
I'm glad that it worked!

@mirogta
Copy link

mirogta commented Feb 17, 2023

@gabrielcartellivia can we close this issue?

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

No branches or pull requests

5 participants