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

JetBrains GoLand Cucumber/Gherkin support for godog #128

Open
ssmythe opened this issue Apr 28, 2018 · 4 comments
Open

JetBrains GoLand Cucumber/Gherkin support for godog #128

ssmythe opened this issue Apr 28, 2018 · 4 comments

Comments

@ssmythe
Copy link

ssmythe commented Apr 28, 2018

Hey there,

I'm a huge fan of Cucumber in Ruby, and am now starting to learn Golang. I was able to get the Gherkin plugin installed to GoLand and the features formatter works great! I installed the Golang Cucumber module godog via:

$ go get github.com/DATA-DOG/godog/cmd/godog

godog homepage: https://github.com/DATA-DOG/godog

I was able to work all the way through FizzBuzz on the command line using godog, yea!

https://github.com/ssmythe/fizzbuzz_using_godog

In GoLand, the step_definitions highlighter obvious doesn't know what to do in the features file, since there's no mapping to the _test.go files. A big difference in how godog supports step_definitions is how it requires the _test.go files in the root directory. Kinda weird, since I really liked having them tucked under the features/step_definitions directory in Ruby.

I'm still working out how to get godog to work with 'go test' on the command line. I'm getting some errors still, but I'm hoping I'll get it soon.

I'm dreaming of the day when godog auto-run test support can be integrated into GoLand much the same way Cucumber is in RubyMine. :-)

Keep up the awesome work godog team!

---- UPDATED: Fri Apr 27 8:42 PM PST

Well, it looks like I got it to work with 'go test', but the test runner in GoLand doesn't seem to like the output to be able to parse the output like it does in RubyMine for Cucumber.

Any suggestions on output formatting so GoLand can parse it?

The automatic test runner works now too! :-D Whoo hoo!

@l3pp4rd
Copy link
Member

l3pp4rd commented Apr 28, 2018

Hi, thanks for trying and responding with your experiences. The reason why step definitions are in _test.go files in the root package directory, mainly are due to the way of golang:

  • each package has test isolation level within a package
  • go builds _test.go files only when running go test (it will never ship to production binary)
  • godog tries to be friendly to go test it also supports integration with it together in order to provide code coverage. (though, maybe in the future it could leverage testing.T)

It still allows you to create the shell command in the root directory, which could run step definitions from the step_definitions.go or whatever file in features directory.

Happy to hear, that you solved the issues. I'm not familiar with RubyMine for Cucumber

@omarkohl
Copy link

It would be great to have GoLand detect what functions map to what scenario steps. When using the Gherkin Plugin the .feature file is highlighted correctly but says "Undefined step reference" on every line.

Also getting autocompletion when writing a new feature file would be great to reduce duplication etc.

Anyone know how to tackle this? Maybe it is something JetBrains themselves would be willing to do or help with?

@ssmythe
Copy link
Author

ssmythe commented May 15, 2018

I posted this issue on the JetBrains GoLand forum, and it was turned into a ticket: https://youtrack.jetbrains.com/issue/GO-5655 Hopefully, we can get the community to help prioritize this ticket to get some traction.

JetBrains has awesome support of Gherkin and Cucumber in RubyMine. If GoLand could behave similarly, I'd be super happy.

@electrofelix
Copy link

Seems that you can hook into Goland provided you use Test_<Feature>(t *testing.T) { ... } to run the test. Looks like Goland is hooking into the test runner at this level to inspect each test in order to track and report what has succeeded/failed on individual tests/subtests.

Maybe a note in the documentation to follow the pattern described at https://youtrack.jetbrains.com/issue/GO-5655#focus=streamItem-27-3547822.0-0 for now and retain TestMain purely for setup/teardown instead of executing godog directly?

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