Add RCP app to testing Classpath

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

Add RCP app to testing Classpath

Postby Otisler » Tue Aug 28, 2007 6:09 am

I'm encountering problems while testing and I was wondering if there are any smart ways around this.
Is there any way I can add my RCP app to my Testing plugin classpath so that I can cast objects as Objects from my RCP app?
Many times I need to access my private variables from a class I wrote and I can't get to them.

I tried adding it to the classpath, but I kept getting ClassCastExceptions.
Is this even possible?

Thanks
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby gnebling » Tue Aug 28, 2007 7:26 am

Add it to your Java Build Path > Projects tab.
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Postby Otisler » Tue Aug 28, 2007 9:20 am

I tried that before, and I tried it again right now. I don't get any compile errors when I build the Test Project. I can Ctrl-Click on the class and it will take me to that class in my RCP app; but when I run it, I get a NoClassDefFoundError
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby Otisler » Tue Sep 18, 2007 9:58 am

I had to go to my RCP app and in the Runtime tab, I had to export all the packages I wanted to be visible by my testing plugin.

This wasn't very clear in any examples, you should probably reiterate this somewhere for clarity sake
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby gnebling » Tue Sep 18, 2007 2:01 pm

Ah, yes. This is a standard Eclipse issue. If you want plugin A to access classes in plugin B, then modify the plugin A's manifest to be dependent upon plugin B. In addition you must modify plugin B's manifest to export those packages you want visible to plugin A.

We've added this to the FAQ.
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Postby Otisler » Fri Sep 21, 2007 1:26 pm

Quick question,
This works fine for running tests from eclipse as long as that project is open. But when i export this and run it headless, it obviously depends on that plugin and those classpaths, so do I have to create a plugin from my application and link that up with my testing?

Is there another way to do it, or an example of the right way to do it?

thanks
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby Dan Rubel » Sat Sep 22, 2007 7:35 am

Yes... When you want to run your tests outside of the Eclipse development environment, the tests must be exported as a separate plugin that is then linked to your exported RCP Application.
Dan Rubel
Moderator
 
Posts: 27
Joined: Thu Oct 30, 2003 9:13 am

Postby Otisler » Mon Sep 24, 2007 6:29 am

Ok, but my question is how to link it.

I had the tests running headless before i put in the dependency on my RCP application. I looked at your "Running WindowTester tests on a RCP Application from Ant" sample and modified it for my needs, and it worked great. But when i did it, my tests didn't depend on anything from my RCP. Now it does, and those class files are no longer there.
How would i go about linking it?

Thanks
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby Otisler » Mon Sep 24, 2007 10:16 am

I got it, thanks
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby Dan Rubel » Mon Sep 24, 2007 10:33 am

2 possible ways to "link" your test code to your RCP application:

Option 1:
place your test plug-in(s) directly into the "plugins" directory of your RCP application. This is by far the easiest approach

-- OR --

Option 2:
(a) create a "links" directory as a sibling to the "plugins" directory of your RCP application
(b) create a "test.link" file in that new "links" directory. The file can be named anything you like so long as it has the ".link" extension.
(c) the new "test.link" file should contain a single key/value pair something like this...

path=C:/Program Files/Instantiations/WindowTester_v2.2.1/E-3.3

Note the forward slashes '/' and absolute path
Dan Rubel
Moderator
 
Posts: 27
Joined: Thu Oct 30, 2003 9:13 am

Postby Otisler » Mon Sep 24, 2007 12:39 pm

Hi, I'm actually still getting some problems, I though I'd fixed it, but its still erroring out.
Let me start from the begininng...
I looked at your examples on running an RCP From ant headless. I modified as little as possible to make it work with my RCP and tests. So I left the directory structure, links, output, everything, the same.

Now after I did this, everything was happy, until I wanted my testing app to reference some classes from my RCP.

When I did this I was getting NoClassDef found errors:

java.lang.NoClassDefFoundError: zbiide/views/SearchView at com.zbiide.autotesting.test.CommonFunctionality.deselectDebugPrinter(CommonFunctionality.java:203) at com.zbiide.autotesting.test.CommonFunctionality.tearDown(CommonFunctionality.java:142) at junit.extensions.UITestCaseCommon.access$101(UITestCaseCommon.java:26) at junit.extensions.UITestCaseCommon$1.run(UITestCaseCommon.java:140) at junit.extensions.core.SequenceRunner$1.run(SequenceRunner.java:69)


And to remedy this, I had to export the packages on my RCP plugin.xml

So I made my testing app depend on my RCP app and then I had to change the RCP app to export the packages (like we talked about in this thread)

After I did this, everything was happy again, when I ran this in eclipse.
When I did run it headless, I was getting errors everywhere saying my RCP app could not be resolved.

So now I had to modify my build.xml file on the testing side. So modifying the target

<target name="@dot" depends="init" unless="@dot" description="Create jar: com.zbiide.autotesting @dot.">
<delete dir="${temp.folder}/@dot.bin"/>
<mkdir dir="${temp.folder}/@dot.bin"/>
<path id="@dot.classpath">
<pathelement path="C:/Program Files/Eclipse/plugins/org.junit_3.8.1/junit.jar"/>
<pathelement path="C:/Program Files/Instantiations/WindowTester_v2.2.1/E-3.2/eclipse/plugins/com.windowtester.runtime_2.2.1/commonRuntime.jar"/>

....


I had to add the following element to the tag to link my test to the RCP

<pathelement path="D:/Software/ZbiIde/bin"/>


Which is the path to the class files of my RCP app


Now, after I add this to the classpath, my tests started running again and I thought it was OK, but when the tests finished, all of them failed out because I was getting NoClassDefFound errors again, (like when i forgot to export the packages) All of them failed because it was in the teardown.


java.lang.NoClassDefFoundError: zbiide/views/SearchView at com.zbiide.autotesting.test.CommonFunctionality.deselectDebugPrinter(CommonFunctionality.java:203) at com.zbiide.autotesting.test.CommonFunctionality.tearDown(CommonFunctionality.java:142) at junit.extensions.UITestCaseCommon.access$101(UITestCaseCommon.java:26) at junit.extensions.UITestCaseCommon$1.run(UITestCaseCommon.java:140) at junit.extensions.core.SequenceRunner$1.run(SequenceRunner.java:69)

And I can't link the testing app by placing the directory in the "plugins" directory of my RCP app because using your example, the two are completely separate (which is actually a lot better for testing)

It seems like the testing app doesn't know that my RCP plugin jar has exported those packages. Is there a different way I have to export that jar now to signify that those packages are exported?
So now I'm stuck here... any thoughts?

thanks
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby Dan Rubel » Mon Sep 24, 2007 1:17 pm

And I can't link the testing app by placing the directory in the "plugins" directory of my RCP app because using your example, the two are completely separate (which is actually a lot better for testing)


Yes... using the links directory and keeping the application and the testing code separate is the better way. Its more complicated, but less chance of the tests contaminating the application.

It seems like the testing app doesn't know that my RCP plugin jar has exported those packages. Is there a different way I have to export that jar now to signify that those packages are exported?
So now I'm stuck here... any thoughts?


I have a couple of questions, some of which are repeats just for completeness and in hopes of getting you back on track quickly:

(1) Does the application export the appropriate packages for the test plugin?
(2) Is the test plugin dependent upon the appropriate application plugins to gain access to the appropriate classes
(3) Eclipse caches plugin metadata information in the "configuration" directory, so is this being cleared each and every time you are running your tests to ensure a clean test?
Dan Rubel
Moderator
 
Posts: 27
Joined: Thu Oct 30, 2003 9:13 am

Postby Otisler » Mon Sep 24, 2007 1:28 pm

Answers for your questions:

1) yes, it pretty much exports all of them right now
2) I'm not so sure on this one. I think this is where my problem might be. Right now it depends on the local project in my eclipse workspace. So when I close the RCP app Project, the test Application dependencies are broken. I try to take care of this in my build.xml (on the test plugin side) to give it the path of the class files. However, I think this may be wrong too. In the @dot target of the build.xml I pass in the path to a folder instead of my plugin.jar. If I give it only the plugin.jar, it won't resolve any of the classes. I'm thinking I'm still exporting my RCP app wrongly.
I'm exporting the right packages, but what should i include in the build.properties? I'm only doing a binary build right now, do i have to do a source build?

3) yes, this aspect is fine. Clean build every time

Thanks
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby Otisler » Tue Sep 25, 2007 1:06 pm

So, is what I want to do even possible? I was thinking about this today.
When I run the tests from Eclipse, I'm running the tests on top of my product which sits in my workspace, and the class files are dynamically loaded.
But headless, the product is now an exported product, loading everything from its jar file. The classes are built up before hand, and then I try to access those class files through the jar while the tests are running.

Does this make any sense as to why it won't work headless?
I don't know if I even follow my own logic, but i've been playing with this for 2 days and driving myself crazy :wink:
Otisler
 
Posts: 28
Joined: Tue Mar 27, 2007 1:24 pm
Location: Vernon Hills IL

Postby Dan Rubel » Tue Sep 25, 2007 8:00 pm

So, is what I want to do even possible?


Yes, this is possible. The key is to get the dependencies as declared in the test plug-in MANIFEST.MF correct as this is what is used by the Eclipse framework to generate the test plug-in's classpath at runtime.

2) I'm not so sure on this one. I think this is where my problem might be. Right now it depends on the local project in my eclipse workspace. So when I close the RCP app Project, the test Application dependencies are broken. I try to take care of this in my build.xml (on the test plugin side) to give it the path of the class files. However, I think this may be wrong too. In the @dot target of the build.xml I pass in the path to a folder instead of my plugin.jar. If I give it only the plugin.jar, it won't resolve any of the classes. I'm thinking I'm still exporting my RCP app wrongly.
I'm exporting the right packages, but what should i include in the build.properties? I'm only doing a binary build right now, do i have to do a source build?


Just to clarify... I'm assuming that you are modifying the test plug-in's MANIFEST.MF file to depend upon the appropriate application plug-in and that you are not modifying the test project's "Projects" tab on the "Java Build Path" page in the project "Properties" dialog... correct?
Dan Rubel
Moderator
 
Posts: 27
Joined: Thu Oct 30, 2003 9:13 am

Next

Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest