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
Resources extension: Consider running tests sequentially when lifecycle methods have resources #685
Comments
Storing something in a static field and then mutating it and then turning on parallel tests is really asking for problems - I'm inclined to "fix" this by adding a sentence or two to the documentation. |
We could also considered ‚Isolated“ |
I don't follow. Can you elaborate? |
Oh, I'd forgotten that The following blurb already exists in the documentation, so I'm wondering if we even need to say any more?
|
I think that's ok. I'm editing the docs as we
|
I like it! It makes it clear what the user should be doing instead. |
When tests and lifecycle methods share the same
@Shared
resource, they are forced to run sequentially, even if parallel tests have been enabled. This prevents methods from mutating the resource at the same time.However, it is a common pattern in JUnit to save some data in a field from inside a lifecycle method. This is error-prone because if a resource is saved in a field by a
@BeforeAll
method, then the@Test
s will run in parallel as they are not annotated with@Shared
directly, and thus they are free to mutate the resource at the same time.To prevent this, we should consider running all tests in a test class sequentially (including all
@Nested
classes) when the class has a lifecycle method with a@Shared
parameter.The text was updated successfully, but these errors were encountered: