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

Potencial improvements to default tests template #98

Open
matrixik opened this issue May 6, 2019 · 3 comments
Open

Potencial improvements to default tests template #98

matrixik opened this issue May 6, 2019 · 3 comments

Comments

@matrixik
Copy link

matrixik commented May 6, 2019

I'm not sure if this will be interesting for this project but Dave Cheney gave nice presentation about writing tests for Go code with some improvements over default template from gotests:
https://dave.cheney.net/paste/gopherchina-2019-testing-talk.pdf

Like having name in map[string]struct instead of []struct or using https://github.com/google/go-cmp Diff for better displaying what differ between outputs (instead of %v).

@mekegi
Copy link
Contributor

mekegi commented May 13, 2019

@matrixik
added PR for cmp.Equal and cmp.Diff in generated tests

for changing from

struct {
   name string
 ...
}

to

  map[string]struct{
 ...
}

I think it's better to create different issue for changing struct slice to map struct

@frenzywang
Copy link
Contributor

I think if we have a complex scenario like if we have in order dependency, the map randomly maybe cause result will be unknown. and if need that map style, generated then manually modify also is easy.

@skovtunenko
Copy link

@matrixik I feel the same. @davecheney wrote a great article about PROs to stick with maps in table-driven tests.
Now, I'm manually changing the generated output from the tool to use map[string]struct.

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