Reputation: 536
I have a test that sometimes fails on the requireSelected()
call, and I can't figure out why.
public void testSimple() {
JRadioButtonFixture fixture = getFixture();
fixture.check();
fixture.requireSelected().requireVisible();
}
I tried changing the code to run on the EDT instead of in the test's main, but none of the fixture's methods are allowed to be invoked from the EDT it seems.
Why does this test fail?
Update: More details:
There isn't anything in the setUp()
.
Here's the failure trace:
Java.lang.AssertionError: [javax.swing.JRadioButton[name='button', text='text', selected=false, enabled=true, visible=true, showing=true] - property:'selected'] expected:<true> but was:<false>
at org.fest.assertions.Fail.fail(Fail.java:87)
at org.fest.assertions.Fail.failIfNotEqual(Fail.java:60)
at org.fest.assertions.BooleanAssert.isEqualTo(BooleanAssert.java:129)
at org.fest.swing.driver.AbstractButtonDriver.assertThatButtonIsSelected(AbstractButtonDriver.java:142)
at org.fest.swing.driver.AbstractButtonDriver.requireSelected(AbstractButtonDriver.java:127)
at org.fest.swing.fixture.JRadioButtonFixture.requireSelected(JRadioButtonFixture.java:288)
Upvotes: 0
Views: 661
Reputation: 1456
I was recently testing with Abbot, FEST precursor, and some failures occurred the same way of yours. In my case, adding a Thread.sleep(300) between the simulation radio.check()
and the verifier radio.requireSelected()
solved the issue.
Give it a try.
Upvotes: 1
Reputation: 2778
You need to specify how the test fails and maybe show the setUp() method. It could be basically anything with the information you've given.
Upvotes: 0