On Fri, 25 Nov 2022 15:04:38 GMT, Lukasz Kostyra <d...@openjdk.org> wrote:

> After implementing CR fixes it turned out that these tests started to fail at 
> random. Upon more investigation it turned out that the order in which JUnit 
> calls test methods matters a lot.

Thank you for getting to the bottom of this.

> In general:
> 1. `@Parametrized.Parameters`-tagged methods are grouped and called first in 
> an undefined moment, before any test class is executed

This was the surprising find, and explains the odd problems you were seeing.

> 2. Then the order is more expected and predictable; for each test class JUnit 
> calls: `@BeforeClass`, constructor, `@Before`, test, `@After`, ..., 
> `@AfterClass`.
> 
> Additionally, Test Class order is selected at random.

Right. This is documented behavior and is (or at least should be) well 
understood. It's why we are careful to avoid mutating static data or global 
state in a `@Test` method (at least not without restoring it in an `@After` 
method).

> That means that modifying a VM-wide setting like Locale cannot reside in 
> `@Parametrized.Parameters` method or in static initializer block.

Yes, this is the conclusion I would draw as well.

-------------

PR: https://git.openjdk.org/jfx/pull/954

Reply via email to