Open Remeic opened 4 years ago
I am having similar issues on Linux!
On both matching standard components (e. g. JButton) and private component (e. g. extending JPanel) I am encountering flickering tests, meaning sometimes the error occurs and sometimes it doesn't. As well as you the component appears in the component hierarchy, what I have found here was, that for the components the tag "showing" was not present (same for you), but the Matcher had "requireShowing=true". Is this maybe causing an issue?
I am still investigating, but I would also be interested what others have to say.
Hi @JKollien, in the initial state of my unit testing i have the same issue on macos, i solved it using
this.setVisible(true)
On my class that extends jframe, but seems "not working" on ubuntu. I'm can't figure out how fix it, i set even settings of robot to wait 500ms before check if a component is showed or not
Hi @JKollien, It`s My first Post. I have a similar event with Mr @Remeic
My Env
In my App src
public class WFrame extends JFrame {
protected JLabel label = null;
protected JButton btn = null;
protected JPanel panel = new JPanel();
public WFrame(String title) {
this.setTitle(title);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300,400);
this.setPane(getContentPane());
this.setVisible(true);
}
private void setPane(Container c) {
c.add(panel.add(getLabel()),BorderLayout.NORTH);
c.add(panel.add(getButton()),BorderLayout.CENTER);
}
protected JLabel getLabel() {
if(this.label == null) {
this.label = new JLabel("Test");
this.label.setText("Test");
}
return this.label
}
my suite tests
package test;
import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
import org.fest.swing.edt.GuiActionRunner;
import org.fest.swing.edt.GuiQuery;
import org.fest.swing.fixture.FrameFixture;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class WFrameTest {
private FrameFixture mockWindow;
@BeforeClass
public static void beforeClass() {
FailOnThreadViolationRepaintManager.install();
}
@Before
public void before() {
WFrame frame = GuiActionRunner.execute(new GuiQuery<WFrame>() {
@Override
protected WFrame executeInEDT() throws Throwable {
return new WFrame("test app");
}
});
mockWindow = new FrameFixture(frame);
mockWindow.show();
}
@After
public void after() {
mockWindow.cleanUp();
}
// healthy
@Test
public void LabelBindDataCheckWithNoTarget() {
mockWindow.label().text().equals("Test");
}
// UnHealthy
@Test
public void LabelBindDataCheckWithTarget() {
mockWindow.label("Test").text().equals("Test");
}
}
my test logs
Is that any Plan ?
Hi, i have to test my java swing ui with assertj swing, on my mac i have no error but on latest and previous ubuntu version, i have this issue Unable to find component using matcher (the stacktrace is at the end of this post)
Running on Java 8 or 11 same issue, assertj swing version 3.17.0 I have to set timeout before testing ui?
Here a snippet code of my tests