godog icon indicating copy to clipboard operation
godog copied to clipboard

Ability to define WHERE step definitions / features are located

Open sumusjack opened this issue 2 years ago • 12 comments

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

sumusjack avatar Oct 17 '22 15:10 sumusjack

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

gnoe avatar Nov 07 '22 10:11 gnoe

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

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

gabrielcartellivia avatar Jan 25 '23 18:01 gabrielcartellivia

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.

roskee avatar Jan 25 '23 18:01 roskee

image image

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

gabrielcartellivia avatar Jan 25 '23 18:01 gabrielcartellivia

add the file names to the paths list.

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

roskee avatar Jan 25 '23 18:01 roskee

add the file names to the paths list.

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

image

didn't work

gabrielcartellivia avatar Jan 25 '23 18:01 gabrielcartellivia

What is the command you executed?

roskee avatar Jan 25 '23 19:01 roskee

Just godog run

gabrielcartellivia avatar Jan 25 '23 19:01 gabrielcartellivia

run go test inside the services directory.

roskee avatar Jan 25 '23 19:01 roskee

worked! thanks @roskee

gabrielcartellivia avatar Jan 25 '23 19:01 gabrielcartellivia

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

gnoe avatar Jan 25 '23 21:01 gnoe

@gabrielcartellivia can we close this issue?

mirogta avatar Feb 17 '23 14:02 mirogta