On Tue, 27 Oct 2020 05:32:47 GMT, Ajit Ghaisas <[email protected]> wrote:
>> modules/javafx.controls/src/test/java/test/javafx/scene/control/ButtonTest.java
>> line 425:
>>
>>> 423:
>>> 424: mouse.dispose();
>>> 425: }
>>
>> just curious: do we have to dispose the mouseFirer? If so, that pattern
>> isn't safe because it will not happen if the test fails.
>
> Hmm.. very good point. I believe, we should use dispose mechanism whenever
> available for a readable cleanup. Both classes MouseEventFirer & StageLoader
> provide dispose method and the user of these classes should use it.
> Now, this can be handled in two ways -
> 1) Keep a reference at test class level - it will be null by default -
> individual tests will create the object and update the class reference - we
> can dispose in cleanup method after the test
> 2) Use Try blocks in tests that use MouseEventFirerer or StageLoader objects
> and dispose them in finally{} blocks.
>
> We can use (1) if many tests in a test class use MouseEventFirerer or
> StageLoader objects - for example ComboBoxTest and use approach (2) if very
> few tests use these classes - for example ButtonTest.
makes sense :)
-------------
PR: https://git.openjdk.java.net/jfx/pull/337