Resources extension: Consider running tests sequentially when lifecycle methods have resources
See original GitHub issueWhen 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.
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Introduction to the Build Lifecycle - Apache Maven
If you want to run the unit tests, run test . This command executes each default lifecycle phase in order ( validate ,...
Read more >List Of JUnit Annotations: JUnit 4 Vs JUnit 5
Annotations is a Java API that enables JVM to recognize the type of the method defined in the test class. There are 'lifecycles...
Read more >JUnit 5 User Guide
The following test class demonstrates the use of @Test methods and all supported lifecycle methods. For further information on runtime semantics ...
Read more >Test lifecycle - Grafana k6
The four distinct lifecycle stages in a k6 test are "init", "setup", ... The teardown function runs, postprocessing data and closing the test...
Read more >DependsOn attribute - AWS CloudFormation
This dependency ensures that the policy is available throughout the resource's lifecycle. For example, imagine that you have a template with a deployment...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I like it! It makes it clear what the user should be doing instead.
I think that’s ok. I’m editing the docs as we ~speak~ write - should I add this sentence?