Home » Eclipse Projects » Eclipse Platform » Help unit testing an RCP Application
| Help unit testing an RCP Application [message #299332] |
Tue, 14 February 2006 15:15  |
Eclipse User |
|
|
|
I' have an RCP based application and would like to tests portions of the
application ui on an automated basis at night using junit and ant. I've
poked around and haven't found anything similar that i can adapt for my
purposes. Any suggestions, guides, examples would be appreciated.
I've tried using the testing "JUnit Plugin Tests and Automated Testing
Framework" with a simple plugin that does nothing more than try to open an
editor and print out the title of the editor. however when i run it via ant
i get the following:
[j
[java] java.vendor=Sun Microsystems Inc.
[java] BootLoader constants: OS=${os}, ARCH=${arch}, WS=${ws}, NL=en_US
[java] Framework arguments: -application
org.eclipse.test.uitestapplication
formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJU nitResul
tFormatter,com.XXX.TestSuite.xml -testPluginName com.XXX.ui.tests -className
com.XXX.ui.tests. TestSuite
[java] Command-line arguments: -application
org.eclipse.test.uitestapplication -dev bin -data c:\workspace
formatter=org.apache.tools.ant.taskde
fs.optional.junit.XMLJUnitResultFormatter,com.XXX.ui.tests.T estSuite.xml -testPluginName
com.XXX.ui.tests -className com.XXX.ui.tests.TestSuite -os ${os} -ws
${ws} -arch ${arch} -consolelog
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.496
[java] !MESSAGE Bundle
update@plugins/org.eclipse.core.resources.win32_3.1.0.jar [15] was not
resolved.
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.556
[java] !MESSAGE Bundle
update@plugins/org.eclipse.swt.win32.win32.x86_3.1.2.jar [65] was not
resolved.
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.586
[java] !MESSAGE Bundle update@plugins/org.eclipse.ui.win32_3.1.0.jar
[89] was not resolved.
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.626
[java] !MESSAGE Bundle
update@plugins/org.eclipse.update.core.win32_3.1.0.jar [95] was not
resolved.
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.886
[java] !MESSAGE An error occurred while automatically activating bundle
org.eclipse.ui.workbench (92).
[java] !STACK 0
[java] org.osgi.framework.BundleException: The activator
org.eclipse.ui.internal.WorkbenchPlugin for bundle org.eclipse.ui.workbench
is invalid
[java] at
org.eclipse.osgi.framework.internal.core.AbstractBundle.load BundleActivator(AbstractBundle.java:149)
[java] at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:965)
[java] at
org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:316)
[java] at
org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:264)
[java] at
org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLoca lClass(EclipseClassLoader.java:116)
[java] at
org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:337)
[java] at
org.eclipse.osgi.framework.internal.core.SingleSourcePackage .loadClass(SingleSourcePackage.java:37)
.
[java] at org.eclipse.core.launcher.Main.run(Main.java:973)
[java] at org.eclipse.core.launcher.Main.main(Main.java:948)
[java] Caused by: java.lang.NoClassDefFoundError:
org/eclipse/swt/SWTError
[java] at java.lang.Class.getDeclaredConstructors0(Native Method)
[java] at
java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
[java] at java.lang.Class.getConstructor0(Class.java:2640)
[java] at java.lang.Class.newInstance0(Class.java:321)
[java] at java.lang.Class.newInstance(Class.java:303)
[java] at
org.eclipse.osgi.framework.internal.core.AbstractBundle.load BundleActivator(AbstractBundle.java:144)
[java] ... 43 more
[java] Root exception:
[java] java.lang.NoClassDefFoundError: org/eclipse/swt/SWTError
[java] at java.lang.Class.getDeclaredConstructors0(Native Method)
[java] at
java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
[java] at java.lang.Class.getConstructor0(Class.java:2640)
[java] at java.lang.Class.newInstance0(Class.java:321)
[java] at java.lang.Class.newInstance(Class.java:303)
[java] at
org.eclipse.osgi.framework.internal.core.AbstractBundle.load BundleActivator(AbstractBundle.java:144)
[java] at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:965)
.
[java] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
[java] at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
[java] at org.eclipse.core.launcher.Main.run(Main.java:973)
[java] at org.eclipse.core.launcher.Main.main(Main.java:948)
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.946
[java] !MESSAGE Application error
[java] !STACK 1
[java] org.eclipse.core.runtime.CoreException[1]:
java.lang.NoClassDefFoundError: org/eclipse/ui/testing/ITestHarness
[java] at java.lang.ClassLoader.defineClass1(Native Method)
[java] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
[java] at
org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.d efineClass(DefaultClassLoader.java:370)
[java] at
org.eclipse.core.runtime.adaptor.EclipseClassLoader.defineCl ass(EclipseClassLoader.java:233)
[java] at
org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.f indClassImpl(DefaultClassLoader.java:343)
[java] at
org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.f indClass(DefaultClassLoader.java:235)
.
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
[java] at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
[java] at org.eclipse.core.launcher.Main.run(Main.java:973)
[java] at org.eclipse.core.launcher.Main.main(Main.java:948)
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:40.16
[java] !MESSAGE Bundle
update@plugins/org.eclipse.core.resources.win32_3.1.0.jar [15] was not
resolved.
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:40.126
[java] !MESSAGE Bundle
update@plugins/org.eclipse.swt.win32.win32.x86_3.1.2.jar [65] was not
resolved.
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:40.257
[java] !MESSAGE Bundle update@plugins/org.eclipse.ui.win32_3.1.0.jar
[89] was not resolved.
[java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:40.317
[java] !MESSAGE Bundle
update@plugins/org.eclipse.update.core.win32_3.1.0.jar [95] was not
resolved.
Any suggestions, guides, examples would be appreciated.
Ross
|
|
|
| Re: Help unit testing an RCP Application [message #299333 is a reply to message #299332] |
Tue, 14 February 2006 15:47   |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Stay tuned ... the presentation for Automated Builds etc. will be up on the EclipseCon website soon (by Feb 17th, in fact ...)
It looks like the workspace is hosed. It will be using the one defined in the 'configuration/' directory, which is possibly the same workspace as you use for running Eclipse normally (and will be the one if you have the workspace set to 'default'). I'd suggest running Eclipse in the same workspace to initialise the metadata properly. Failing that, I can recommend that you run the below with -clean and -initialise and then -application afterwards to ensure the data is initialised poperly.
Of course, I'm assuming that you're running in a workspce that has these plugins already. Bear in mind that the workspace that is run may not be the same as the workspace that you're editing with. If you're using the 'basebuilder' to host the plugins, then it may be the case that it doesn't have the core.resources plugin (I've not looked, but it does contain a subset of what's needed).
I'm assuming that you're using the 'runtests' script to launch it, which calls the -application org.eclipse.test.uitestapplication, and the org.eclipse.test plugins are installed in the workspace that's being used, because those are both necessary. You might also like to try running it with -workspace /some/workspace/you/know/about to ensure that you've got the right one; most problems are usually traced to not initialised workspaces.
So, that's a little bit of help along the way, but I'm not sure that it will help. Debugging this stuff is a bit of a black art. What are you using to automate the builds at night?
Alex.
|
|
|
| Re: Help unit testing an RCP Application [message #299334 is a reply to message #299333] |
Tue, 14 February 2006 17:01   |
Eclipse User |
|
|
|
Still no luck. I initialized a separate workspace with the separate instance of eclipse I have installed for testing. I also went
and modified the library.xml in the org.eclipse.test plugin to supply the -clean -Initialized parameters. My test plugin is also in
the %EclipseHome%\plugins directory.
However after launch the ant task again using ant -file "test.xml" I am still getting the same error.
We are using cruisecontrol to manage our nightly build process.
Ross
"Alex Blewitt" <automatic@javalobby.org> wrote in message news:2450661.1139950055371.JavaMail.root@cp1.javalobby.org...
> Stay tuned ... the presentation for Automated Builds etc. will be up on the EclipseCon website soon (by Feb 17th, in fact ...)
>
> It looks like the workspace is hosed. It will be using the one defined in the 'configuration/' directory, which is possibly the
> same workspace as you use for running Eclipse normally (and will be the one if you have the workspace set to 'default'). I'd
> suggest running Eclipse in the same workspace to initialise the metadata properly. Failing that, I can recommend that you run the
> below with -clean and -initialise and then -application afterwards to ensure the data is initialised poperly.
>
> Of course, I'm assuming that you're running in a workspce that has these plugins already. Bear in mind that the workspace that is
> run may not be the same as the workspace that you're editing with. If you're using the 'basebuilder' to host the plugins, then it
> may be the case that it doesn't have the core.resources plugin (I've not looked, but it does contain a subset of what's needed).
>
> I'm assuming that you're using the 'runtests' script to launch it, which calls the -application
> org.eclipse.test.uitestapplication, and the org.eclipse.test plugins are installed in the workspace that's being used, because
> those are both necessary. You might also like to try running it with -workspace /some/workspace/you/know/about to ensure that
> you've got the right one; most problems are usually traced to not initialised workspaces.
>
> So, that's a little bit of help along the way, but I'm not sure that it will help. Debugging this stuff is a bit of a black art.
> What are you using to automate the builds at night?
>
> Alex.
|
|
|
| Re: Help unit testing an RCP Application [message #299350 is a reply to message #299334] |
Wed, 15 February 2006 09:14   |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
Why not try running the command line outside of the ant.xml environment?
All you need to do is run the -application against the standard launcher.
java -cp %EclipseHome%\startup.jar
-data c:\TheWorkspace
-application org.eclipse.test.uitestapplication
-formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,MyTestClass.xml
-testPlugin my.test.plugin
-className MyClassTest
You might see other stuff happening in the window that you don't see from ant. There may also be other command line options that the uitestapplication takes (have a look at its source in CVS; I don't know any off the top of my head, but -verbose is a possibility).
I'd also recommend that you try launching exactly the same way, but use org.eclipse.ui.ide.workbench instead of the application (and lose everything else afterwards). That way, you're simulating a normal start-up with exactly the environment that the UI plugin is expecting, and you can do things like see what plugins are installed or gleam extra information from the startup process.
The library.xml is a pretty horribly written Ant script anyway (the reason they say the you must specify OS and WS on non-windows platforms is that they're using
<arg line="-os ${os}"/>
[/xml]
when they should be using
<arg value="-os"/>
<arg value="${os}"/>
[/xml]
The build scripts aren't terribly great; they serve their purpose, but not always as stable as you'd like. Still, they work for what they were designed for; building Eclipse.
CruiseControl is definitely a good way of kicking it off, though. If you've got enough patience, investing in Maven can also be a good way of automating these things ... but this case is probably independent of which tool you're using to kick it off. I'd recommend getting the workspace running by using a manual command line, then once that's sorted, run it with the uitests application instead. Once you've verified that it works with all of the above, then switch to using the library.xml (or write your own :-). Chances are, although you have created your own workspace, the uitests application might be reading from a completely different one (it defaults to whatever is in config.ini, and if that doesn't work, usually ~/workspace). It can seem a bit random at times.
Alex.
|
|
|
| Re: Help unit testing an RCP Application [message #302507 is a reply to message #299332] |
Sat, 22 April 2006 03:34  |
Eclipse User |
|
|
|
I had the same problem, and I think I found the solution.
If you note below the line that says "BootLoader constants:", look at
the values of OS, etc. They are not being specified.
Here is what I did in my test.xml to work around the problem (note the
property specifications of os, ws, and arch).
<target name="suite">
<property name="compare-folder"
value="${eclipse-home}/compare_folder"/>
<delete dir="${compare-folder}" quiet="true"/>
<ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="os" value="linux"/>
<property name="ws" value="gtk"/>
<property name="arch" value="x86"/>
<property name="data-dir" value="${compare-folder}"/>
<property name="plugin-name" value="${plugin-name}"/>
<property name="classname" value="com.oaklandsw.transform.AllTests"/>
</ant>
</target>
This got me past this hurdle.
Francis
Ross wrote:
> I' have an RCP based application and would like to tests portions of the
> application ui on an automated basis at night using junit and ant. I've
> poked around and haven't found anything similar that i can adapt for my
> purposes. Any suggestions, guides, examples would be appreciated.
>
>
>
> I've tried using the testing "JUnit Plugin Tests and Automated Testing
> Framework" with a simple plugin that does nothing more than try to open an
> editor and print out the title of the editor. however when i run it via ant
> i get the following:
>
> [j
>
> [java] java.vendor=Sun Microsystems Inc.
>
> [java] BootLoader constants: OS=${os}, ARCH=${arch}, WS=${ws}, NL=en_US
>
> [java] Framework arguments: -application
> org.eclipse.test.uitestapplication
> formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJU nitResul
>
> tFormatter,com.XXX.TestSuite.xml -testPluginName com.XXX.ui.tests -className
> com.XXX.ui.tests. TestSuite
>
> [java] Command-line arguments: -application
> org.eclipse.test.uitestapplication -dev bin -data c:\workspace
> formatter=org.apache.tools.ant.taskde
>
> fs.optional.junit.XMLJUnitResultFormatter,com.XXX.ui.tests.T estSuite.xml -testPluginName
> com.XXX.ui.tests -className com.XXX.ui.tests.TestSuite -os ${os} -ws
> ${ws} -arch ${arch} -consolelog
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.496
>
> [java] !MESSAGE Bundle
> update@plugins/org.eclipse.core.resources.win32_3.1.0.jar [15] was not
> resolved.
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.556
>
> [java] !MESSAGE Bundle
> update@plugins/org.eclipse.swt.win32.win32.x86_3.1.2.jar [65] was not
> resolved.
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.586
>
> [java] !MESSAGE Bundle update@plugins/org.eclipse.ui.win32_3.1.0.jar
> [89] was not resolved.
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.626
>
> [java] !MESSAGE Bundle
> update@plugins/org.eclipse.update.core.win32_3.1.0.jar [95] was not
> resolved.
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.886
>
> [java] !MESSAGE An error occurred while automatically activating bundle
> org.eclipse.ui.workbench (92).
>
> [java] !STACK 0
>
> [java] org.osgi.framework.BundleException: The activator
> org.eclipse.ui.internal.WorkbenchPlugin for bundle org.eclipse.ui.workbench
> is invalid
>
> [java] at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.load BundleActivator(AbstractBundle.java:149)
>
> [java] at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:965)
>
> [java] at
> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:316)
>
> [java] at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:264)
>
> [java] at
> org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLoca lClass(EclipseClassLoader.java:116)
>
> [java] at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:337)
>
> [java] at
> org.eclipse.osgi.framework.internal.core.SingleSourcePackage .loadClass(SingleSourcePackage.java:37)
>
> .
>
> [java] at org.eclipse.core.launcher.Main.run(Main.java:973)
>
> [java] at org.eclipse.core.launcher.Main.main(Main.java:948)
>
> [java] Caused by: java.lang.NoClassDefFoundError:
> org/eclipse/swt/SWTError
>
> [java] at java.lang.Class.getDeclaredConstructors0(Native Method)
>
> [java] at
> java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
>
> [java] at java.lang.Class.getConstructor0(Class.java:2640)
>
> [java] at java.lang.Class.newInstance0(Class.java:321)
>
> [java] at java.lang.Class.newInstance(Class.java:303)
>
> [java] at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.load BundleActivator(AbstractBundle.java:144)
>
> [java] ... 43 more
>
> [java] Root exception:
>
> [java] java.lang.NoClassDefFoundError: org/eclipse/swt/SWTError
>
> [java] at java.lang.Class.getDeclaredConstructors0(Native Method)
>
> [java] at
> java.lang.Class.privateGetDeclaredConstructors(Class.java:23 28)
>
> [java] at java.lang.Class.getConstructor0(Class.java:2640)
>
> [java] at java.lang.Class.newInstance0(Class.java:321)
>
> [java] at java.lang.Class.newInstance(Class.java:303)
>
> [java] at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.load BundleActivator(AbstractBundle.java:144)
>
> [java] at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:965)
>
> .
>
> [java] at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> [java] at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> [java] at java.lang.reflect.Method.invoke(Method.java:585)
>
> [java] at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
>
> [java] at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
>
> [java] at org.eclipse.core.launcher.Main.run(Main.java:973)
>
> [java] at org.eclipse.core.launcher.Main.main(Main.java:948)
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:39.946
>
> [java] !MESSAGE Application error
>
> [java] !STACK 1
>
> [java] org.eclipse.core.runtime.CoreException[1]:
> java.lang.NoClassDefFoundError: org/eclipse/ui/testing/ITestHarness
>
> [java] at java.lang.ClassLoader.defineClass1(Native Method)
>
> [java] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
>
> [java] at
> org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.d efineClass(DefaultClassLoader.java:370)
>
> [java] at
> org.eclipse.core.runtime.adaptor.EclipseClassLoader.defineCl ass(EclipseClassLoader.java:233)
>
> [java] at
> org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.f indClassImpl(DefaultClassLoader.java:343)
>
> [java] at
> org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.f indClass(DefaultClassLoader.java:235)
>
> .
>
> [java] at java.lang.reflect.Method.invoke(Method.java:585)
>
> [java] at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
>
> [java] at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
>
> [java] at org.eclipse.core.launcher.Main.run(Main.java:973)
>
> [java] at org.eclipse.core.launcher.Main.main(Main.java:948)
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:40.16
>
> [java] !MESSAGE Bundle
> update@plugins/org.eclipse.core.resources.win32_3.1.0.jar [15] was not
> resolved.
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:40.126
>
> [java] !MESSAGE Bundle
> update@plugins/org.eclipse.swt.win32.win32.x86_3.1.2.jar [65] was not
> resolved.
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:40.257
>
> [java] !MESSAGE Bundle update@plugins/org.eclipse.ui.win32_3.1.0.jar
> [89] was not resolved.
>
> [java] !ENTRY org.eclipse.osgi 2006-02-14 15:04:40.317
>
> [java] !MESSAGE Bundle
> update@plugins/org.eclipse.update.core.win32_3.1.0.jar [95] was not
> resolved.
>
>
>
> Any suggestions, guides, examples would be appreciated.
>
>
>
>
>
> Ross
>
>
>
>
|
|
|
Goto Forum:
Current Time: Thu Nov 06 14:16:16 EST 2025
Powered by FUDForum. Page generated in 0.04256 seconds
|