On Sun, 15 Sep 2024 23:53:20 GMT, Jay Bhaskar <[email protected]> wrote:
>> modules/javafx.web/src/test/java/test/javafx/scene/web/SubresourceIntegrityTest.java
>> line 99:
>>
>>> 97: @ParameterizedTest
>>> 98: @MethodSource("dataProvider")
>>> 99: public void testScriptTagWithCorrectHashValue() {
>>
>> Major: This methods need the parameters from the `MethodSource` AFAIK, that
>> is:
>> `testScriptTagWithCorrectHashValue(String hashValue, String expected) { .. }`
>>
>> The member variables should be removed then:
>> ```
>> private final String hashValue = "";
>> private final String expected = "";
>
> In this case, keeping the values as instance variables is more reliable.
> Since all the tests pass when hashValue and expected are instance variables
> and some of them fail when I adding parameter to
> testScriptTagWithCorrectHashValue ,
>
> it's likely that their assignment happens at the correct time relative to the
> @BeforeEach setup. Using parameters may interfere with the test lifecycle,
> since hasValue is being used in
> @BeforeEach
> public void setup() ....{}
>
> it's safer and more straightforward to use instance variables.This would
> also make it easier to manage the state across @BeforeEach
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.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1567#discussion_r1761017166