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

Request: option to provide features not from filesystem #328

Closed
zhammer opened this issue Jul 3, 2020 · 7 comments
Closed

Request: option to provide features not from filesystem #328

zhammer opened this issue Jul 3, 2020 · 7 comments

Comments

@zhammer
Copy link

zhammer commented Jul 3, 2020

Hi, I'm curious if y'all would be up allowing a way to provide feature files to godog.TestSuite that is not just passing file paths. Our use case is that we'd like to package a test tool as a binary using godog and ship features as static files in the binary using https://github.com/markbates/pkger. Here we'd have he feature file bodies and names; however, the TestSuite wouldn't be able to parse them from a list of filesystem Paths.

Happy to discuss different ways this could work!

godog/options.go

Lines 54 to 55 in 28ad994

// All feature file paths
Paths []string

@lonnblad
Copy link
Member

lonnblad commented Jul 3, 2020

Sounds interesting, maybe when building the godog testrunner we could have an include functionality that would embed the feature dirs/files you pass as arguments.

Something like: > godog build --include --output godog.test features would build a test runner binary which embeds the features dir.

@zhammer
Copy link
Author

zhammer commented Jul 3, 2020

Yep that’d be nice. We have our own golang cli that uses the godog package directly so wouldn’t immediately need the cli option, but I do like the idea of including packaged feature files in the godog cli tool itself

@lonnblad
Copy link
Member

Were you thinking something like:

type GherkinFile struct {
  Name    string
  Content []byte
}

type Options struct {
  ...
  Files []GherkinFile
}

and let your code read the content from pkger?

@lcarrazana
Copy link

Looking for the exact same functionality.
I'm using pkger for embedding all static files, and would like to also do it for godog feature files.

@lonnblad
Copy link
Member

lonnblad commented Mar 5, 2021

@lcarrazana would you want to use it in a similar way as zhammer, or would you use the godog CLI directly?

@vearutop
Copy link
Member

Now that Go provides standard embed package, this feature might be especially interesting for building portable test runners with embedded test scenarios.

We can follow the approach used in https://github.com/pressly/goose/pull/244/files (setting base fs of runner and keeping paths) to implement such feature with minimal API changes.

@vearutop
Copy link
Member

Done with #476.

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

4 participants