Automate Tests Using Ant

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Automate Tests Using Ant

Postby nartubitak » Mon Mar 07, 2011 8:07 am

Hi,

I have an RCP application. I recorded tests for it. I can run these tests as JUnit Plug-in Test within Eclipse.

I have problems when I try to automate these tests using ant.

Environment:
    OS: Ubuntu 10.04 LTS - the Lucid Lynx, 2.6.32-28-generic #55-Ubuntu SMP Mon Jan 10 23:42:43 UTC 2011 x86_64 GNU/Linux
    Java:
      (default)java version "1.6.0_24", Java(TM) SE Runtime Environment (build 1.6.0_24-b07), Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
      (alternatif)java version "1.6.0_24",Java(TM) SE Runtime Environment (build 1.6.0_24-b07),Java HotSpot(TM) Server VM (build 19.1-b02, mixed mode)
    Development: Eclipse Helios SR2 32 bit
      In eclipse.ini file, “-vm /usr/lib/jvm/ia32-java-6-sun/bin/java” is added
      Eclipse is run with this command "./eclipse -vm /usr/lib/jvm/ia32-java-6-sun/bin/java"

1) When I try to run the command (run by eclipse) in command prompt

/usr/lib/jvm/ia32-java-6-sun-1.6.0.24/bin/java -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:44636 -Dosgi.requiredJavaVersion=1.5 -XX:MaxPermSize=256m -Xms40m -Xmx512m -Declipse.pde.launch=true -Declipse.p2.data.area=@config.dir/p2 -Dfile.encoding=UTF-8 -classpath /home/narin/Desktop/eclipse_SR2_32bit/eclipse/plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar org.eclipse.equinox.launcher.Main -os linux -ws gtk -arch x86 -nl tr -consoleLog -version 3 -port 55532 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames xxxplugintest.XXXTest -application org.eclipse.pde.junit.runtime.uitestapplication -product KSMPlugin.product -data /home/narin/workspace_dnm/../junit-workspace -configuration file:/home/narin/workspace_dnm/.metadata/.plugins/org.eclipse.pde.core/pde-junit/ -dev file:/home/narin/workspace_dnm/.metadata/.plugins/org.eclipse.pde.core/pde-junit/dev.properties -os linux -ws gtk -arch x86 -nl tr -consoleLog -testpluginname XXXTest

I get that error

Code: Select all
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
Aborted



2) If I remove the "-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:44636" from the command, the application starts to run, but the automatic test does not start and says
Code: Select all
Could not connect to:  : 55532         
java.net.ConnectException: Connection refused
   at java.net.PlainSocketImpl.socketConnect(Native Method)
   at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
   at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
   at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
   at java.net.Socket.connect(Socket.java:529)
   at java.net.Socket.connect(Socket.java:478)
   at java.net.Socket.<init>(Socket.java:375)
   at java.net.Socket.<init>(Socket.java:189)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.connect(RemoteTestRunner.java:570)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:381)
   at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
   at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.run(UITestApplication.java:116)
   at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
   at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
   at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
   at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
   at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at ksmplugin.KSM.start(KSM.java:33)
   at org.eclipse.pde.internal.junit.runtime.UITestApplication.start(UITestApplication.java:47)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
   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 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
   at org.eclipse.equinox.launcher.Main.main(Main.java:1384)


3) I tried to define ant task as in http://code.google.com/javadevtools/win ... estreports.
Code: Select all
<project default="test-html" name="runTest">   
   <property name="tst-dir" location="." />
   <property name="test.reports" value="./reports" />
   <property name="eclipse_location" value="/home/narin/Desktop/eclipse_SR2_32bit/eclipse" />

   <path id="classpath.base">
   </path>

   <path id="classpath.test">
      <pathelement location="${eclipse_location}/plugins/org.junit_4.8.1.v4_8_1_v20100427-1100/junit.jar"/>
       <pathelement location="${tst-dir}/bin" />
      <pathelement location="/bin" />
       <path refid="classpath.base" />
   </path>
   
   <target name="test-html" >

      <junit fork="yes" printsummary="yes" haltonfailure="no">
         <batchtest fork="yes" todir="${test.reports}">
            <fileset dir="${tst-dir}">
               <include name="xxxplugintest/XXXTest.class" />
            </fileset>
         </batchtest>
         <formatter type="xml" />
         <classpath refid="classpath.test" />
      </junit>

      <junitreport todir="${test.reports}">
         <fileset dir="${test.reports}">
            <include name="TEST-*.xml" />
         </fileset>
         <report todir="${test.reports}" />
      </junitreport>

   </target>
</project>


I get the following result but test does not start
Code: Select all
Buildfile: /home/narin/workspace_dnm/KSMPluginTest/runTest.xml

test-html:
[junitreport] Processing /home/narin/workspace_dnm/KSMPluginTest/reports/TESTS-TestSuites.xml to /tmp/null1512494821
[junitreport] Loading stylesheet jar:file:/home/narin/Desktop/eclipse_SR2_32bit/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] Transform time: 134ms
[junitreport] Deleting: /tmp/null1512494821
BUILD SUCCESSFUL
Total time: 321 milliseconds


4) I tried sample: http://www.eclipse.org/articles/article ... index.html. But it needs javac which is not in "/usr/lib/jvm/ia32-java-6-sun/bin/java" and is designed for Eclipse 3.3.

Can you help me to run tests from command prompt?
Thanks in advance
nartubitak
 
Posts: 5
Joined: Tue Oct 06, 2009 12:42 am

Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest

cron