JComboBoxFixture.selectItem don't always work as expected
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Reproduce the loop from the issue, including selection by index and text and the explicit-click workaround. Start at the JComboBoxFixture.selectItem entry point and investigate why selection sometimes remains at index 0. Done means repeated runs select the requested item reliably without requiring a preceding click.
Written by the indexing model from the issue text.
Description
Hi Joel.
First of all, thank you for your very interesting work. I've been using assertJ-core and assertJ-swing for several weeks now (and I like it a lot), but I'm experiencing random failures in my tests when playing with comboboxes.
Consider the following loop :
for (int i = 0; i < 10; i++) {
GuiActionRunner.execute(() -> {
JComboBox<String> combo = new JComboBox<>();
combo.addItem("item_1");
combo.addItem("item_2");
jFrame = Containers.frameFor(combo);
jFrame.setName(this.getClass().getName());
jFrame.setVisible(true);
});
FrameFixture frame = new FrameFixture(jFrame);
frame.comboBox().selectItem(1);
frame.comboBox().requireSelection(1); // **** randomly fails *****
frame.cleanUp();
}
A ComparisonFailure is thrown most of the time, after a random number of iterations.
org.junit.ComparisonFailure: [javax.swing.JComboBox[name=null, selectedItem='item_1', contents=["item_1", "item_2"], editable=false, enabled=true, visible=true, showing=true] - property:'selectedIndex'] expected:<[1]> but was:<[0]>
I found a workaround by explicitly clicking on combo before selecting item.
frame.comboBox().click().selectItem(1);
I noticed the problem whenever selecting items using index or text.
What do you think ? Am I missing something or is it actually an issue ?
Regards
- Dominant language
- Java
- Stars
- 121
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from assertj/assertj-swing
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
assertj/assertj-swing#279 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
assertj/assertj-swing#278 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
assertj/assertj-swing#276 · 1 comment ·
-
Update unit test to avoid deprecated `ExpectedException.none()` by using `Assert.assertThrows()` Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
assertj/assertj-swing#275 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
assertj/assertj-swing#277 · 1 comment ·
All issues in assertj/assertj-swing
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
checkstyle/test-configs#263 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
1.0.0-alpha2 Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#272 ·