Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Test snippet should support Parallel execution by default #2291

Closed
a-h opened this issue Jan 30, 2019 · 4 comments
Closed

Test snippet should support Parallel execution by default #2291

a-h opened this issue Jan 30, 2019 · 4 comments
Labels
snippets feature requests regarding addition of snippets

Comments

@a-h
Copy link

a-h commented Jan 30, 2019

Currently, the tdt snippet produces the following code:

func Test(t *testing.T) {
	testCases := []struct {
		desc	string
		
	}{
		{
			desc: "",
			
		},
	}
	for _, tC := range testCases {
		t.Run(tC.desc, func(t *testing.T) {
			
		})
	}
}

This is useful, but doesn't make use of parallel execution as per https://golang.org/pkg/testing/#hdr-Subtests_and_Sub_benchmarks

So my proposal is that they change to add this in (and match the naming convention in the docs).

func Test(t *testing.T) {
	tests := []struct {
		name	string
	}{
		{
			name: "",

		},
	}
	for _, tc := range tests {
		tc := tc
		t.Run(tc.name, func(t *testing.T) {
			t.Parallel()
			
		})
	}
}

It needs 10 thumbs up on the issue to be considered, so please vote if you think it's a good change!

@lggomez
Copy link
Contributor

lggomez commented Jan 31, 2019

Is it a good idea to have it as the default?

Altough these should be edge cases, there is a certain possibility of testing code which doesn't support parallel execution due to shared package state, like in-memory caches being used from the tests

@a-h
Copy link
Author

a-h commented Jan 31, 2019

Good point. I don't think we should optimise for the edge case though. If 99% of the time, when you write a test, it's safe for parallel execution, then I think that should be the default.

@lggomez
Copy link
Contributor

lggomez commented Feb 1, 2019

I agree. It's completely reasonable, considering that the user will have to edit the created code anyway and therefore be conscious about what it does

@ramya-rao-a ramya-rao-a added the snippets feature requests regarding addition of snippets label Aug 26, 2019
@stamblerre
Copy link
Contributor

As per #2380 (comment), we will be pausing development on snippets so that we can reevaluate all of the extension's snippets as a whole. I am sorry, but I'm going to go ahead and close this issue. However, I have noted your suggestion here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
snippets feature requests regarding addition of snippets
Projects
None yet
Development

No branches or pull requests

4 participants