godog
godog copied to clipboard
trying and failing :-(
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?
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.
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.
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
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)
I tried ""./mystuff" and ""./mystuff/" and "/mystuff/" and "mystuff/" and "/mystuff" and just "mystuff" but all combinations are failing :-(
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?
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