RFR: 8342602: Remove JButton/PressedButtonRightClickTest test
Damon Nguyen
dnguyen at openjdk.org
Mon Oct 28 22:56:59 UTC 2024
On Fri, 18 Oct 2024 16:41:43 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
> The `javax/swing/JButton/PressedButtonRightClickTest.java` test that was added by [JDK-8049069](https://bugs.openjdk.org/browse/JDK-8049069) fully duplicates an existing test `javax/swing/JButton/bug4490179.java`.
>
> To save time running tests, I'm removing `PressedButtonRightClickTest.java`.
Marked as reviewed by dnguyen (Committer).
> > > Even though the tests verify slightly different conditions, the effect is the same. The button must remain pressed when right mouse button is pressed and released.
> >
> >
> > But it's still a different condition, and removing the test will reduce coverage.
>
> No, it will not reduce the coverage. If `model.isPressed()` returns `true`, it means the action event isn't triggered; if `model.isPressed()` becomes `false`, the action event is triggered.
>
> Both tests verify _the same end result_: no action event is triggered if mouse button 3 is pressed and released while mouse button 1 is pressed. `bug4490179.java` does it explicitly whereas `PressedButtonRightClickTest.java` does it implicitly by checking the state of the button model.
Looking at both of these tests, it does look like the coverage will remain the same. Looks like there's just two ways to test the same functionality, and the original issue reported for each bug is virtually identical.
If removing one test is actually problematic, you could edit the remaining test to check for both `isPressed()` and for the action event trigger, but that seems unnecessary. And I think checking for the action event rather than the state of the button just makes more sense.
Removing the suggested test seems right to me. The additional test was probably just created due to not knowing the older test existed as mentioned.
-------------
PR Review: https://git.openjdk.org/jdk/pull/21587#pullrequestreview-2400384457
PR Comment: https://git.openjdk.org/jdk/pull/21587#issuecomment-2442805006
More information about the client-libs-dev
mailing list