RFR: 8265439: [TestBug] Enable and fix ignored unit tests in MenuItemTest

Ajit Ghaisas aghaisas at openjdk.java.net
Mon Apr 19 16:59:40 UTC 2021


On Mon, 19 Apr 2021 12:51:06 GMT, Ajit Ghaisas <aghaisas at openjdk.org> wrote:

> This PR enables ignored unit tests from MenuItemTest and fixes them.
> 4 ignored tests are fixed. 
> 2 ignored tests are removed.
> 2 new tests are added.
> 
> **Before fix :**
> total tests = 89
> failures = 0
> ignored tests =  6
> 
> **After fix :**
> total tests = 89
> failures = 0
> ignored tests =  0

modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuItemTest.java line 240:

> 238:     @Ignore // calling textProperty will no ensure text value is non null
> 239:     @Test public void unsetTextButNotNull() {
> 240:         MenuItem mi2 = new MenuItem();

Test was incorrect. The value of the 'text' property is not set and asserting on not null is incorrect.

modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuItemTest.java line 287:

> 285:     @Ignore // Again, calling graphicPropery() is not ensuring a non null graphic
> 286:     // node.
> 287:     @Test public void unsetGraphicButNotNull() {

Test was incorrect. The value of the 'graphic' property is not set and asserting on not null is incorrect.

modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuItemTest.java line 410:

> 408: 
> 409:     @Test(expected=NullPointerException.class)
> 410:     public void setSpecifiedAccelerator_nullKeyCombination1() {

Constructing KeyCodeCombination with a null KeyCode & constructing a KeyCharacterCombination with null key character results in NullPointerException as present in KeyCombinationTest.java.

These tests were ignored with a comment on similar lines. I have enabled them and added expected NullPointerException.

modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuItemTest.java line 426:

> 424: 
> 425:     @Test public void setSpecifiedAccelerator1() {
> 426:         Modifier[] modifierArray = {};

Added a test case for valid KeyCodeCombination.

modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuItemTest.java line 432:

> 430:     }
> 431: 
> 432:     @Test public void setSpecifiedAccelerator2() {

Added a test case for valid KeyCharacterCombination.

modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuItemTest.java line 458:

> 456: 
> 457:     @Test public void acceleratorCanBeBound() {
> 458:         KeyCombination kc = new KeyCharacterCombination("A", KeyCombination.ALT_DOWN);

Corrected the test case by creating a valid KeyCombination.

modules/javafx.controls/src/test/java/test/javafx/scene/control/MenuItemTest.java line 464:

> 462:     }
> 463: 
> 464:     @Test public void getUnspecifiedMnemonicParsing() {

Test was incorrect. I have corrected it.
Default value of mnemonicParsing property of MenuItem is true.

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

PR: https://git.openjdk.java.net/jfx/pull/466


More information about the openjfx-dev mailing list