How to run auto gui test cases in AWT thread?


(uyentvu) #1

All,

I am using a JUnit GUI testing framework called WindowTester to auto test my GUIs. When I ran my auto gui test cases using ant, they seemed to work fine. However, when I ran my auto gui test cases using gradle, I kept getting this error “not in AWT thread”.

Does anyone know how to configure/force the auto gui tests using WindowTester running in AWT thread?

Thanks in advance!

Below is the assetion error I got every time I ran the auto gui tests:

java.lang.AssertionError: Not in AWT thread

at com.abc.ui.DataList.getSelectedItems(DataList.java:787)

at com.abc.ui.ListControl.refilter(ListControl.java:151)

at com.abc.ui.ListControl.access$600(ListControl.java:40)

at com.abc.ui.ListControl$SelectedEmitterListener.valueChanged(ListControl.java:252)

at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)

at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:147)

at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:194)

at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:388)

at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:398)

at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:442)

at com.abc.ui.SpaceList$SpaceListSelectionModel.setSelectionInterval(SpaceList.java:274)

at javax.swing.JTable.setRowSelectionInterval(JTable.java:2129)

at com.abc.windowtester.util.JTableHelper.setRowSelectionInterval(JTableHelper.java:13)

at com.abc.windowtester.util.HighPerfUITestCaseSwing.setRowSelectionInterval(HighPerfUITestCaseSwing.java:161)

at com.abc.windowtester.TrainPopupMenuItemsStatusAutoTest.testTrainPopupMenuItemsStatus(TrainPopupMenuItemsStatusAutoTest.java:71)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at junit.framework.TestCase.runTest(TestCase.java:168)

at junit.framework.TestCase.runBare(TestCase.java:134)

at com.windowtester.runtime.common.UITestCaseCommon.access$0(UITestCaseCommon.java:1)

at com.windowtester.runtime.common.UITestCaseCommon$2.run(UITestCaseCommon.java:130)

at com.windowtester.runtime.common.UITestCaseCommon$3.run(UITestCaseCommon.java:151)

at com.windowtester.internal.runtime.junit.core.SequenceRunner$1.run(SequenceRunner.java:40)


(Stefan Sieber) #2

This doesn’t sound like a gradle problem to me, but maybe I got something wrong.

  • How do you execute the tests? - Did you use a special Ant - Task when running the Tests from Ant? - Are the tests normal JUnit - tests which just happen to reference a special testing Library (windowtester)? - maybe you can share parts of the gradle build script?

(uyentvu) #3

Here is how I execute the GUI tests using Gradle command: >gradle runAutoGuiTests

Below is my task defined in Gradle:

task runAutoGuiTests(type: Test) {

beforeTest { descriptor ->

logger.lifecycle("Running: " + descriptor)

}

include ‘com/abc/windowtester/**AutoTest.*’

}

I do not use any special Ant task at all. However, when I use Ant to run my Ant target called runAutoGuiTests, it ran successfully. Our project was using Ant to build in the past. I am migrating our project to Gradle at the moment.

We use WindowTester to automate the process of our GUI testings and run the tests using Gradle.

Thanks.