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

snippet: Add table testing boilerplate snippet #1956

Merged
merged 1 commit into from
Sep 11, 2018

Conversation

mtyurt
Copy link
Contributor

@mtyurt mtyurt commented Sep 8, 2018

The snippet only considers string input / output, and it needs to be modified for each test case, but it provides a clean, parallel testing compatible table testing boilerplate code.

Let me know if you have suggestions about tab stops or snippet name.

@arp242
Copy link
Contributor

arp242 commented Sep 8, 2018

Thanks!

This seems very specific for your personal use-case though. I'm not sure if adding it to vim-go is a good idea.

(also, as a general point, you should probably use subtests and print errors as aligned output).

@mtyurt
Copy link
Contributor Author

mtyurt commented Sep 10, 2018

Thanks for the feedback. If you don't see any future even when it's modified properly according to Effective Go best practices, I can keep this one in my personal snippets :)

@arp242
Copy link
Contributor

arp242 commented Sep 10, 2018

If that is from Effective Go then that document should be updated/changed.

@bhcleek
Copy link
Collaborator

bhcleek commented Sep 10, 2018

@mtyurt, if you'll modify it so that each entry in the table has a name, the tests are run via `

t.Run(tt.name, func(t *testing.T) {
   ...
})

and all the snippet is available to all of vim-go's supported engines, I'm sure we can get this merged.

@mtyurt mtyurt force-pushed the table-test-snippet branch 2 times, most recently from 1da487a to 2643b75 Compare September 11, 2018 09:43
@mtyurt
Copy link
Contributor Author

mtyurt commented Sep 11, 2018

I have updated the snippet to use subtests and added minisnip / neosnip versions as well.

@fatih
Copy link
Owner

fatih commented Sep 11, 2018

This looks good. Only change I would recommend is to change the name testtable (it's a tad long). Let's use tt.

@mtyurt
Copy link
Contributor Author

mtyurt commented Sep 11, 2018

That's quite a better name, I hope it doesn't confuse people :)

Renamed to tt

@fatih
Copy link
Owner

fatih commented Sep 11, 2018

@mtyurt true, but then a long name means you need to write a lot, which is an anti-pattern for a snippet. We already have many 2-3 char snippets (i.e: err, errf, hf, etc..). People get used to it so it's not a big issue :)

@fatih fatih merged commit e45ccaa into fatih:master Sep 11, 2018
@mtyurt mtyurt deleted the table-test-snippet branch September 11, 2018 10:38
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

Successfully merging this pull request may close these issues.

4 participants