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

trying and failing :-( #173

Open
marcelloh opened this issue Apr 24, 2019 · 7 comments
Open

trying and failing :-( #173

marcelloh opened this issue Apr 24, 2019 · 7 comments
Labels
❓ question Consider using support forums: https://cucumber.io/tools/cucumber-open/support

Comments

@marcelloh
Copy link

marcelloh commented Apr 24, 2019

So I have a feature file inside the features folder., and I have a test file inside some package folder "mystuff". Inside it there a file called "Abbreviate.go". How can I tell godog to use the Abbreviate_test.go in the same "mystuff" folder (but it has the package "mystuff_test")

I've looked for more info, but I find it unclear from documentation where files should be and what they should contain.
I tried with the testmain option, but it starts complaining about missing colors and other stuff
:-(
Let's just start with some basic example where people have subdirectories: where can I find such example?

@l3pp4rd
Copy link
Member

l3pp4rd commented Apr 24, 2019

Hi, godog works the same as go test you must have all test files in package you are testing. Go cannot import tests from other packages, that is the language limitation. You may define godog contexts in other package, but it cannot be a _test.go file in order to import it in a package you are testing.

@l3pp4rd l3pp4rd added the ❓ question Consider using support forums: https://cucumber.io/tools/cucumber-open/support label Apr 24, 2019
@marcelloh
Copy link
Author

this is actually not true. You can have a test in the same directory "mystuff" but in a different package "mystuff_test".

But as the feature file is in features/mystuff.feature, I think godoc looks only in that directory for corresponding test files.

Perhaps I should write a test file inside the features directory with "features_test" as the package, calling the functions to test from "mystuff". But I can guess, but I think that others have done this before me, since I'm not the first to try godog.

@l3pp4rd
Copy link
Member

l3pp4rd commented Apr 24, 2019

godog looks only in the current directory you run from. If go supports looking for test files in packages suffixed by _test then I was not aware of it and would need to check the specs again. But at the moment, it does not matter where you have your feature files, it only matters from which package godog is run from. it compiles only that directory and searches for the contexts in test files

@marcelloh
Copy link
Author

so I go inside the mystuff directory whenre I put the mystuff.feature and the mystuff_test.go file?
How can I test all my packages then?
Should I make a MAKE file?
better I do it with go test ./... because it will find every test I have in every (sub)package.

So I can do the first now :-)
But running a go test ./... because it complains about the
feature path "features" is not available.

I have this:
os.Args = []string{
args[0],
"-f", "progress",
"features",
}
but wonder what I have to type instead of "features".
I've tried "mystuff" but it tells me:
feature path "mystuff" is not available.
btw I'm running this from the root (where the mystuff directory is a child)

@marcelloh
Copy link
Author

I tried ""./mystuff" and ""./mystuff/" and "/mystuff/" and "mystuff/" and "/mystuff" and just "mystuff"
but all combinations are failing :-(

@marcelloh
Copy link
Author

marcelloh commented Apr 24, 2019

when I do "." I get a stack trace so maybe I'm on the right path.
I think this is the way to have a test set which I can run, or am I missing something?

@l3pp4rd
Copy link
Member

l3pp4rd commented Apr 24, 2019

in most of the cases godog is used for functional tests and it is run from a single package, which contains all the public user facing interface. given it is an API, in that case you would have a main package, which starts a http server or in other case if it is a command line tool, a cmd subdirectory with a main package to build that command line interface binary. The test files, features and contexts are placed in that main package.

just look into examples and godog library itself. or for example minishift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question Consider using support forums: https://cucumber.io/tools/cucumber-open/support
Projects
None yet
Development

No branches or pull requests

2 participants