RFR: 8339515: [TestBug] Convert web tests to JUnit 5 [v6]
Jay Bhaskar
jbhaskar at openjdk.org
Mon Sep 16 15:35:19 UTC 2024
On Mon, 16 Sep 2024 14:54:43 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> I think you need to do the same as done by @andy-goryachev-oracle in his JUnit5 replacement PR:
>>
>> public void setup(String hashValue, String expected) throws Exception {
>> htmlFile = new File("subresource-integrity-test.html");
>> ...
>> }
>>
>> @ParameterizedTest
>> @MethodSource("dataProvider")
>> public void testScriptTagWithCorrectHashValue(String hashValue, String expected) {
>> setup(hashValue, expected);
>> ...
>> }
>>
>>
>> This way you dont need the instance fields, as they will be empty all the time and never assigned.
>
> @Maran23 is right. In the absence of support for parameterized class-level tests the easiest solution (I think) is to parameterize every `@Test`, which means:
> - add parameters to each method, replace `@Test` with `@ParameterizedTest` and `@MethodSource`
> - add parameters to setup method (`@Before`, remove the annotation)
> - call the setup method from each test method
> - remove the fields that were set in the constructor and the constructor itself
>
> Things might be a bit more complicated in the case of test class hierarchies, so additional work and checks will be needed.
still some tests fail, after applying solution as suggested.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1567#discussion_r1761384513
More information about the openjfx-dev
mailing list