UI tests on MAC (JUnit, Fest) [message #721168] |
Thu, 01 September 2011 05:28  |
Eclipse User |
|
|
|
I wrote a test that uses FEST to open a JFrame and then the AWT Robot to perform some actions. It works fine on Windows. On Mac, if I run the same class as a Java App (ie. main()) then it works there too. But if I run it as a JUnit plugin test, the frame is never shown, the mouse is stuck in the middle of the screen, and lots of these errors are generated...
2011-08-23 16:37:37.686 java[87274:10c03] *** -[NSConditionLock
unlock]: lock (<NSConditionLock: 0x1006a5b90> '(null)') unlocked when
not locked
2011-08-23 16:37:37.686 java[87274:10c03] *** Break on _NSLockError() to debug.
I made an even simper test without FEST and when run as either a Java App or a JUnit test, I get the above errors and the button isn't manually clickable during the pause before things end (but it is on Windows) - the mouse pointer changes to the busy cursor over the frame.
Any ideas what's going on here? I tried removing some of the cmd line options that said online caused issues in similar cases but that didn't help. And the only other things I found searching were Eclipse Bugs 106769, 268420, 295670.
Here's my env (with a few things ellipsed out)...
!SESSION 2011-09-01 00:46:12.932 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_26
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments: -version 3 ... -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames ....MacTests -application org.eclipse.pde.junit.runtime.coretestapplication -testpluginname ...
Command-line arguments: -os macosx -ws cocoa -arch x86_64 -consoleLog -version 3 ... -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames ....MacTests -application org.eclipse.pde.junit.runtime.coretestapplication -data /Users/remote/workspace/../junit-workspace -dev file:/Users/remote/workspace/.metadata/.plugins/org.eclipse.pde.core/pde-junit/dev.properties -os macosx -ws cocoa -arch x86_64 -consoleLog -testpluginname ...
Here are my tests...
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import junit.framework.TestCase;
import org.fest.swing.edt.GuiActionRunner;
import org.fest.swing.edt.GuiQuery;
import org.fest.swing.fixture.FrameFixture;
public class JavaRobotExample extends TestCase
{
Robot robot = new Robot();
public static void main(String[] args) throws AWTException
{
new JavaRobotExample();
}
public void testRobot() throws AWTException
{
new JavaRobotExample();
}
public JavaRobotExample() throws AWTException
{
showFrame();
robot.setAutoDelay(40);
robot.setAutoWaitForIdle(true);
robot.delay(4000);
robot.mouseMove(40, 130);
robot.delay(500);
System.exit(0);
}
private void showFrame()
{
JFrame frame = GuiActionRunner.execute(new GuiQuery<JFrame>()
{
@Override
protected JFrame executeInEDT()
{
String testName = "Mac Frame Test";
JFrame frame = new JFrame(testName);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton btn = new JButton("Click Me");
btn.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
System.out.println("Hello World!");
}
});
JTextField field = new JTextField();
frame.add(field);
frame.pack();
return frame;
}
});
FrameFixture win = new FrameFixture(frame);
win.show(new Dimension(1000, 1000));
win.moveToFront();
win.moveTo(new Point(0,0));
}
}
=====
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import junit.framework.TestCase;
public class MacTests extends TestCase
{
public static void main(String[] args)
{
new MacTests().testFrame();
}
public void testFrame()
{
String testName = "Mac Frame Test";
JFrame frame = new JFrame(testName);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton btn = new JButton("Click Me");
btn.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
System.out.println("Hello World!");
}
});
frame.add(btn);
frame.pack();
frame.setVisible(true);
frame.requestFocus();
frame.setAlwaysOnTop(true);
pause(10); // wait 10 secs
}
}
|
|
|
Re: UI tests on MAC (JUnit, Fest) [message #721755 is a reply to message #721168] |
Fri, 02 September 2011 18:17   |
Eclipse User |
|
|
|
Ok, so I wrote a simple test using the example here...
docs DOT codehaus DOT org/display/FEST/Base+TestCase+%28TestNG+and+JUnit%29
Outside Eclipse it runs fine as a Java App and as a JUnit test. Inside Eclipse the latter fails. I don't know where to begin on settings to adjust to make it work in the IDE.
(again this is on Mac/OSX only - it runs fine in Eclipse on Windows)
|
|
|
Re: UI tests on MAC (JUnit, Fest) [message #725350 is a reply to message #721168] |
Wed, 14 September 2011 14:59   |
Eclipse User |
|
|
|
Simple test that shows a JFrame and uses Java Robot to click on it. Works fine run in Eclipse on Mac as an application or JUnit test but fails when run as JUnit plugin test. Frame would show 1 out of 5 or so times. Removing all unneeded plugins results in frame always being shown but the click never seems to happen.
Is this related to the args that Eclipse uses to run plugin tests on Mac? Or the core plugins included to run the tests? Or...?
|
|
|
Re: UI tests on MAC (JUnit, Fest) [message #725707 is a reply to message #725350] |
Thu, 15 September 2011 14:59   |
Eclipse User |
|
|
|
I also tried Window Licker and the included Calculator test(s) - same thing... runs as a JUnit Test but fails as a JUnit Plugin Test. One time the frame was shown, but nothing happened (so the test failed). The other times, the frame didn't even show. Tried removing all VM args and unnecessary plugins.
No suggestions/pointers/anything?
|
|
|
Re: UI tests on MAC (JUnit, Fest) [message #726239 is a reply to message #725707] |
Fri, 16 September 2011 21:19  |
Eclipse User |
|
|
|
Ok seems to be mostly related to this:
bugs dot eclipse dot org/bugs/show_bug.cgi?id=133072
Removing all of the default jvm and prog args (especially -ws) got most of the tests working. What still fails at this point is any time a pop-up is shown - like a button that has a drop-down or a context menu.
|
|
|
Powered by
FUDForum. Page generated in 0.03538 seconds