nikolaymatrosov / cucumber-go

Apache License 2.0
9 stars 1 forks source link

Step not linked when using "fmt" #36

Open lopezdonaque opened 1 month ago

lopezdonaque commented 1 month ago

Hi, your plugin is really helpful! Thanks for it!

I found this issue trying it. When I use "fmt" the step is found, but not linked in the feature file.

// Works
ctx.Step(`^there are (\d+) godogs$`, func() {})

// Does not work
ctx.Step(fmt.Sprintf(`^there are %s godogs$`, `(\d+)`), func() {})

Goland 2024.1.4 Plugin 0.2.1

nikolaymatrosov commented 1 month ago

I will definitely look at how to add this functionality. But I can't promise that I'll do it quickly.

SpencerC commented 1 month ago

This would be a great thing to add. The challenge is that since any code could be executed in the course of a fmt.Sprintf statement, you actually have to run the code to find out what the step definitions are. I think there are three options for doing this:

  1. Use godog's ShowStepDefinitions mode (also may be possible with the --optOverrides.definitions=false flag, but I haven't tried it).
  2. Generate a program that uses reflect to inspect the godog configuration, similar to what GoMock does.
  3. Document a workaround for developers, such as requiring them to write their own code to generate fully expanded step definitions and store them in a temporary file somewhere for the plugin to pick up. I might experiment with this one, and will post the results.