-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
TestScenario-less testing #65
Comments
I've been thinking about it for a while. We need more discussion on that. Firstly, there has to be an instance of GoBDD alive, somewhere. What comes to my mind is "global" instance initialized in the library's We have to autoload/register those functions somehow. What we can do is parsing test functions looking for functions + comments in a certain format. Something ala annotations. // GoBDD I add (\d+) and (\d+)
func add(ctx context.Context, var1, var2 int) error {
...
} As I said previously, it doesn't look a very Go's way of doing stuff. The second option sounds doable but there are more questions to answer like:
We can talk about it but I don't think that such functionality will land in v1.0. |
You can use so called "markers" as annotation like constructs. I used them in a project of mine for code generation. Reference: https://book.kubebuilder.io/reference/markers.html |
That looks neat and certainly go-compatible. I've ran into such annotations/comments on https://magefile.org/ and it works really well there. @bkielbasa any drawbacks you would think of using this approach? So far I can only think of positives :-) |
Thanks for your comments! To be honest, I don't have any good reason to not do it. func TestScenarios(t *testing.T) {
NewSuite(t, WithAutoload()).Run()
} IMO this is the minimal code needed to run such code. |
@mirogta note that build tags are not the same as markers. Build tags go to the beginning of a file and look like Markers are just comments and look like @bkielbasa godog provides an executable for running scenarios without having to write a test method. Personally I prefer having an explicit test method though. |
can you give an example? |
I'll admit, I don't know how that works internally. |
ok, I give the green light to do it but first of all, we have to have a more detailed specification. If you have any idea how to make it work just open an issue with the proposal (example #72). |
I'm closing it but I'll create a separate proposal in the future for markers |
Is your feature request related to a problem? Please describe.
I love the way steps in PowerShell tests using Pester/Gherkin are matched. You call Given/When/Then funcs and pass the regex matching string as the first parameter. See https://powershellexplained.com/2017-03-17-Powershell-Gherkin-specification-validation/
Compared to
go-bdd
orgodog
as well in a similar way, both need code where you match the English text from the feature files to a func. Sure, this code can be generated or suggested (as godog does), but it's just noise.See
Describe the solution you'd like
What I would like to achieve in a "better" Go BDD test library is to avoid that extra func.
Would it be possible to have the regex text part of the func that implements it, something like:
or inside the TestScenarios?
Describe alternatives you've considered
N/A
Additional context
This would make this so much awesome-er than godog ;-)
The text was updated successfully, but these errors were encountered: