Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Running Parallel Tests in Suite #187
Reviving this issue. Presumably it should be possible to run suite tests in parallel.
The problem with parallelism here is that the suite members used in tests have a shared single instance for all. Tests running in parallel could potentially access these members at the same time, causing them to "collide" with each other via these members.
However, my suggestion is that testify will add a special
This will of course require extra work from the test developer, to make sure
I have a test suite runner here that supports testing.T.Parallel().
The problem with supporting parallel execution on Suite is that the TestingSuite's public interface T() returns a *testing.T. It is very hard to make this goroutine safe. Rather than wrapping access to the returned *testing.T, I went down the path of removing the dependencies on the Suite struct's internal state, and simply pass the internal tests' *testing.T in via function arguments.
This removes the ability to call Assert() on the testing suite, but is a minior inconvenience IMO because the assert package supports passing a *testing.T object into it's functions.
Let me know how you all feel about this strategy. I will work on cleaning up that branch and adding docs/tests for a pr if it works for you.
referenced this issue
Nov 18, 2016
I just whipped up a slightly different approach to running tests in parallel:
Similar to #369, it introduces a
Because a new suite is initialised before every test, it means tests can't share data on the suite struct. This is a change in behaviour, though I imagine you could change the patch to make a copy of the suite struct instead of initialising a new one (that way tests could still share data and setup/teardown code using
I actually prefer the share-nothing approach though; it feels like a bad practice to modify data on the suite struct while tests are running, especially now in parallel. I can't see why tests should ever share data (outside what is set up in
@dansimau I think your approach is closer to the current architecture of testify's Suite.
Otherwise the work done in the SetupSuite function calls will be lost.